4
บูลีนตัวดำเนินการตามเงื่อนไขและการทำกล่องอัตโนมัติ
ทำไมถึงโยน NullPointerException public static void main(String[] args) throws Exception { Boolean b = true ? returnsNull() : false; // NPE on this line. System.out.println(b); } public static Boolean returnsNull() { return null; } ในขณะที่สิ่งนี้ไม่ public static void main(String[] args) throws Exception { Boolean b = true ? null : false; …