0

Anybody explain the output?

public class Main { public static void main(String[] args) { int x= 010; int y= 6; System.out.println(x); System.out.println(y); } } output is :8 & 6 . explain how is it 8...

23rd Dec 2016, 10:28 AM
Santosh kumar M
Santosh kumar M - avatar
5 Respostas
+ 4
The literal expression which is assigned to the x var is an octal ( 8-base ) notation: in Java, octal numbers starting with a 0 ;)
23rd Dec 2016, 10:36 AM
visph
visph - avatar
+ 2
ASCII Octal number of 8 is 010. Look at the table: http://www.asciitable.com/index/asciifull.gif
23rd Dec 2016, 10:34 AM
Uran Kajtazaj
Uran Kajtazaj - avatar
+ 2
@Uran Kajtazaj: It isn't necessary an Ascii code, it's just an integer value ^^
23rd Dec 2016, 10:38 AM
visph
visph - avatar
+ 2
@Uran Kajtazaj: I already answered: It isn't necessary an Ascii code, it's just an integer value ^^
23rd Dec 2016, 10:43 AM
visph
visph - avatar
+ 1
please explain the difference of my answer with yours
23rd Dec 2016, 10:40 AM
Uran Kajtazaj
Uran Kajtazaj - avatar