//如果object為null,則設置為defaultValue ObjectUtils.defaultIfNull(object, defaultValue); //判斷集合是否為null List<String> list=new ArrayList<String>(); System.out.println(list.isEmpty()); //true System.out.println(list.size()); //0 Set<String> set=new HashSet<String>(); System.out.println(set.isEmpty()); //true System.out.println(set.size()); //0 Map<String, String> map=new HashMap<String, String>(); System.out.println(map.isEmpty()); //true System.out.println(map.size()); //0 方法一(數據量大,效率低): if(list!=null && list.size()>0){ } 方法二(數據量大,效率高): if(list!=null && !list.isEmpty()){ }
---------------------------------------------------------------------------------
Blog:http://www.cnblogs.com/linjiqin/
Hadoop交流群(250363249)、Java+Oracle交流群(158560018)
題外話:
本人來自鐵觀音的發源地——泉州安溪,有需要正宗安溪鐵觀音的友友歡迎Q我:416501600。