Neil
Neil

Reputation: 5

Data types in Java

class Test
{
      public  static void main(String[] args)
      {
              double a= 0786;
              System.out.println(a);

 
      }
}

//Why does double a=0786 gives error (integer number too large) ?

Upvotes: 0

Views: 133

Answers (1)

Jon Skeet
Jon Skeet

Reputation: 1500075

An integer literal with a leading 0 is an octal literal, and 8 isn't a valid digit within octal literals.

If you actually want a value of 786 decimal, just remove the leading 0:

double a = 786;

Upvotes: 2

Related Questions