首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

开发惯用方法集锦(持续更新中)

2012-12-22 
开发常用方法集锦(持续更新中)1. 判断对象是否为空.public static boolean empty(Object obj){if (obj

开发常用方法集锦(持续更新中)
1. 判断对象是否为空.

public static boolean empty(Object obj)  {    if (obj == null)      return true;    if ((obj instanceof String) && (((obj.equals("")) || (obj.equals("0")))))      return true;    if ((obj instanceof Number) && (((Number)obj).doubleValue() == 0.0D))      return true;    if ((obj instanceof Boolean) && (!((Boolean)obj).booleanValue()))      return true;    if ((obj instanceof Collection) && (((Collection)obj).isEmpty()))      return true;    if ((obj instanceof Map) && (((Map)obj).isEmpty())) {      return true;    }    return (obj instanceof Object[]) && (((Object[])obj).length == 0);  }

热点排行