Java?е????????????
???????????? ???????[ 2015/4/10 14:18:01 ] ????????Java ??????? ??? ????
???????????????Java 1.5????????????????????????????????????????????????????????????????Java??????????????????????????????????????????????????????
???????????Java1.5????й?????????????????????????????????????(Collections)?з?????????????????????????????????????????????????????Щ?????????????????????Щ??????????????С????Integer??Double??Boolean????Щ???????????????????????????????????Щ????????????????????????????????????????Java 1.5??????????????????????????????????????????????????????????????????????????????Щ????????????и????????????????????????????????bug??
??????????????????????????????????????????????????????????
??????????????????
????????????Java???????????????????????????罫int??????????Integer??????????????????????Integer?????????int????????????????????????????????????????????е??????????????????????????????????byte??short??char??int??long??float??double??boolean??????????Byte??Short??Character??Integer??Long??Float??Double??Boolean??
????????????????
?????????????????????valueOf??????????????????????????????????????????????intValue()??doubleValue()????????????????????????????
?????????????boolean??????Boolean????byte??????Byte????char?????Character????float??????Float????int?????Integer??long?????Long??short?????Short??????????????????????
?????????????????????
????????????????Java?к???????????????????????????????????????????????????????????????????????Java??????????????????????????????????????????????????????ArrayList??????????????????????????????????????????????????????????ThreadLocal??
????ArrayList<Integer> intList = new ArrayList<Integer>();
????intList.add(1); //autoboxing - primitive to object
????intList.add(2); //autoboxing
????ThreadLocal<Integer> intLocal = new ThreadLocal<Integer>();
????intLocal.set(4); //autoboxing
????int number = intList.get(0); // unboxing
????int local = intLocal.get(); // unboxing in Java
???????????
??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
????????
???????????????????????Java 1.5????????????????????????У??????????е???????????????????ɡ?
????//before autoboxing
????Integer iObject = Integer.valueOf(3);
????Int iPrimitive = iObject.intValue()
????//after java5
????Integer iObject = 3; //autobxing - primitive to wrapper conversion
????int iPrimitive = iObject; //unboxing - object to primitive conversion
?????????????
?????????????????????????????????????????????????????????????????????????????????????????
????public static Integer show(Integer iParam){
????System.out.println("autoboxing example - method invocation i: " + iParam);
????return iParam;
????}
????//autoboxing and unboxing in method invocation
????show(3); //autoboxing
????int result = show(3); //unboxing because return type of method is Integer
????show????????Integer???????????????????show(3)?????int??????????Integer??????????ν????????show????????Integer??????int result = show(3);??result?int??????????????????????????????show??????????Integer?????????int???
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11