Concat operation on string and null keyword
问题 As per my understanding, when + operator is used with two string literals, concat method is invoked to produce the expected string. Example - String s = "A" + "B"; When there is null in place of one literals as below then it is generating below output. I am confused here - why it is not throwing NullPointerException ? String str = null + "B"; System.out.println(str); Output: nullB 回答1: why it is not throwing NullPointerException . Because, string concatenation applies string conversion