0
What is happening inside the System.out.println("1"+a);
int a=1; If 1 is a char then output is 50 but if 1 is a string output is 11 .can you clarify with what is happening if 1 is a string ?
6 Réponses
+ 2
Hello pavan
Normally + means you add some numbers, right?
But in case of Strings it concatenate them.
"solo" + "learn" = "sololearn"
"1" + "1" = "11"
+ 2
Tq Denise once again
+ 1
pavan
"1" is not an integer. It is a String.
int i = 1; an integer
String s = "1"; a String
+ 1
In case of a is an integer, println() converts it to a String because "1" is a String. I guess Java wanted to avoid an error message (normally you can't add a string with an integer).
int a = 3;
System.out.println("1" + 3);
Output: "13"
0
Tq Denise
Are you telling that integer is directly converted into string wihout ASCII values?
0
In parantheses( "1" +a) where a is interger right