项目中常见NPE空指针异常
BigDecimal 转 String
BigDecimal bigDecimal = null;
System.out.println("bigDecimal.toString() = " + bigDecimal.toString());
String 转 BigDecimal
String string = null;
BigDecimal bigDecimal = new BigDecimal(string);
System.out.println("bigDecimal = " + bigDecimal);
List<String> list = null;
String s = list.get(0);
System.out.println("s = " + s);
UserInfo userInfo = null;
String userName = userInfo.getUserName();
System.out.println("userName = " + userName);
String aa = null;
boolean bb = aa.equals("bb");
System.out.println("bb = " + bb);
List<String> strings = null;
List<String> strings1 = Collections.emptyList();
System.out.println("strings = " + strings); // null
System.out.println("strings1 = " + strings1); // []
boolean empty = CollUtil.isEmpty(strings);
boolean empty1 = CollUtil.isEmpty(strings1);
System.out.println("empty = " + empty); // true
System.out.println("empty1 = " + empty1); // true
String str = null;
Map map = new ConcurrentHashMap<>();
map.put(str,"abc");
map.put("aaa",null);
System.out.println("map = " + map);
ZoneInfo zoneInfo = null;
zoneInfo.setName("aaa");
System.out.println("zoneInfo = " + zoneInfo);