This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Value of int i=012; Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "Value of int i=012;" Watch "Value of int i=012;" New topic
Author

Value of int i=012;

Biju Warrier
Greenhorn

Joined: Mar 31, 2003
Posts: 2
public class Oct{
public static void main(String argv[]){
Oct o = new Oct();
o.amethod();
}
public void amethod(){
int oi= 012;
System.out.println(oi);
}
}
:roll: :roll:
karl koch
Ranch Hand

Joined: May 25, 2001
Posts: 388
tricky stuff to spot (unless the classname is Oct :-) )
starting with '0' indicates octal. 012 => 10
(1 * 8 + 2 * 1)
starting with '0x' indicates hex. 0x12 => 18
(1 * 16 + 2 * 1)
k
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Value of int i=012;
 
Similar Threads
fundamentals
int primitive
confusing output
Calendar roll back
why the long value print 10 ,not 12 ?