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
Integer iAmNull = null;
int i = iAmNull; // Remember - No Compilation Error
Integer tt = null;
System.out.println((tt instanceof Integer) ? "true" : "false");
//StringUtils methods are null safe, they don‘t throw NullPointerException
System.out.println(StringUtils.isEmpty(null));//true
System.out.println(StringUtils.isBlank(null));//true
System.out.println(StringUtils.isNumeric(null));//\false
System.out.println(StringUtils.isAllUpperCase(null));//false
Person ram = new Person("ram");
int phone = ram.getPhone();
原文:http://www.cnblogs.com/linux007/p/5777971.html