byte[] b1 = null;
byte[] b2 = null;
System.out.println(b1 + b2); // 1
System.out.println("" + b1 + b2); // 2
if I uncomment 1 it’s giving compilation error.
if I uncomment 2 it’s printing nullnull;
so what’s happening here?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Line 2 is doing an implicit cast to String of both arrays and concatenating them, which is valid. In line one you are attempting to apply the add operator to two byte arrays, which is not supported.