我寫了下面的代碼,並輸出I想到的是「你好世界」自動裝箱在哈希表返回NULL
我得到空,可以將某些人解釋的行爲。
import java.util.*;
public class Test {
static HashMap<Integer,String> hm = new HashMap<Integer, String>();
public static void main(String args[]) {
byte b = 1;
hm.put(1, "Hello World");
String s = hm.get(b);
System.out.println("The result is: " + s);
}
}