Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

assigning 09 to int datatype in java  RSS feed

 
v.v. krishnan
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
public class numbers
{
public static void main(String s[])
{
int a =09;
int b = 08;
System.out.println( a + b);
}
}

when i try to assign the value 08 (or) 09 in java it throws an compile time error "09 too large" "08 too large". it compiles fine if i use anything less than 08. any suggestion please.
 
Mani Ram
Ranch Hand
Posts: 1140
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When you preceed a number with a zero, it denotes that the number is a Octal number. Since the range of Octal number is from 0 to 7, the compiler gives an error when you try to assign a value greater than 7.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!