Java???й?Null??9????
???????????? ???????[ 2014/12/31 11:12:54 ] ????????Java ??????? ???
????????Java??????????null????????????????????????????????NPE??????????Java????????????????????????????Java????????null???null????????????????????????Java?????????null??????????????????????????鷳??????null????????Java??
??????????е????棬???java?????????????????飬???????????????????????????????????????????null?????????????e??????????????????????????????????null??Java???????????????????????????????null?????????????null?????е????????????????????null???????????null??
?????????Java???????null???????????null?????Java?????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????Java??null??????????????????е????????null???????????????Щ???????????????????????Щ????null?????μ????????????????????Java??null???Щ??????ɡ?
????Java?е?Null??????
?????????????????????null??Java??????????????null??????????????Щ??????????????????????????????????????????????????????????????Java???????????????????????????У??????????Java??null?????????????????????Щ????????????????null?????????α???????????????
????1???????null??Java?е????????public??static??final???????Сд??е???????nullд??Null??NULL???????????????????????????
????Object obj = NULL; // Not Ok
????Object obj1 = null //Ok
??????????????????????????????????????????IDE??????????????????????????????????????????????IDE??Eclipse??Netbeans???????????????????????????????notepad??Vim??Emacs????????????????????????
????2???????????????????????????int?????0??boolean???????false??null???κ?????????????????????????????object????????????????????????????????????????false??????????????Java?е??κ????????????null???????????????б????????????????????????????????????????????????????????????????г??????????????????????????????????????????????????????????????????????????????????????????????????????
????private static Object myObj;
????public static void main(String args[]){
????System.out.println("What is value of myObjc : " + myObj);
????}
????What is value of myObjc : null
????????????????object????????????????????????????????????myObj???????????????????????????????????????????????????????????????????÷?????????
????3????????????Щ???null?????????????????????????????????????????????丳???κ??????????????????null??????κ??????????????????
????String str = null; // null can be assigned to String
????Integer itr = null; // you can assign null to Integer also
????Double dbl = null; // null can also be assigned to Double
????String myStr = (String) null; // null can be type cast to String
????Integer myItr = (Integer) null; // it can also be type casted to Integer
????Double myDbl = (Double) null; // yes it's possible?? no error
????????????????????????????null?????????κ??????????????е????????????????????????????
????4??null??????????????????????null?????????????????????int??double??float??boolean??????????????????????????????????????
????int i = null; // type mismatch : cannot convert from null to int
????short s = null; // type mismatch : cannot convert from null to short
????byte b = null: // type mismatch : cannot convert from null to byte
????double d = null; //type mismatch : cannot convert from null to double
????Integer itr = null; // this is ok
????int j = itr; // this is also ok?? but NullPointerException at runtime
????????????????????????????null??????????????????????????????????null??????????object?????object???????????????????????????????????????????????????????????????Java?е?????????μ???????????????????????
??????
???·???
??????????????????
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