5
Boolean.valueOf () terkadang menghasilkan NullPointerException
Saya memiliki kode ini: package tests; import java.util.Hashtable; public class Tests { public static void main(String[] args) { Hashtable<String, Boolean> modifiedItems = new Hashtable<String, Boolean>(); System.out.println("TEST 1"); System.out.println(modifiedItems.get("item1")); // Prints null System.out.println("TEST 2"); System.out.println(modifiedItems.get("item1") == null); // Prints true System.out.println("TEST 3"); System.out.println(Boolean.valueOf(null)); // Prints false System.out.println("TEST 4"); System.out.println(Boolean.valueOf(modifiedItems.get("item1"))); // Produces …