看板 java 關於我們 聯絡資訊
public class ShortCircuit { public static void main(String[] args) { String s=null; if((s != null) && s.length() > 20) System.out.println(s); String t=null; if((t != null) & t.length() > 20) System.out.println(t); } } 如題,第一個if不會印出東西,(短路運算子) 第二個if為什麼會有NullPointerException呢? 謝謝回應 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 220.229.203.88