but in runtime it prints that result is null, that...
# announcements
a
but in runtime it prints that result is null, that’s what I’m saying
🧵 1
k
Maybe because in Java when a String is
null
and is treated as
"null"
if we apply String operations other than condition checking For eg in Java:
Copy code
String s1 = null;
String s2 = "test";
String s3 = s1 + s2;
System.out.println(s3);
The above snippet prints
nulltest
.
@Chris Cunningham @hudsonb ?
So as it is forced to return
String
then guess it is returning
"null"
but at time of condition checking it is unboxed sort of as a
null
.
If the reference is null, it is converted to the string
"null"
https://docs.oracle.com/javase/specs/jls/se8/html/jls-5.html#jls-5.1.11