I have the following class:
public class Go {
public static void main(String args[]) {
System.out.println("G" + "o");
System.out.println('G' + 'o');
}
}
And this is compile result;
Go
182
Why my output contain a number?
In the second case it adds the unicode codes of the two characters (G – 71 and o – 111) and prints the sum. This is because
charis considered as a numeric type, so the+operator is the usual summation in this case.