Java中常用的方法

枚举:

1:DemoEnum.valueOf(String str)  从枚举类中中找字符串,如果有则返回对应枚举值

2:DemoEnum.values()      获得枚举集合

3:DemoEnum.property.name()    将枚举类型的属性转为String

集合循环:

1:demolist.forEach(oneDemo ->{循环的方法体})  desc:1.8新特性,函数式编程

2:BeanUtils.copyProperties(Object source,Object target)    desc::将source对象中与target对象相同的属性字段注入到target对象中。

3:demoList.stream().filter(oneDemo -> condition)。findAny().orElse(null)    desc:从集合中查找符合条件的对象并返回,如果没有则返回null。

StringUtils常用方法:

1. public static boolean isEmpty(String str)
判断某字符串是否为空,为空的标准是str==null或str.length()==0

2. public static boolean isBlank(String str)
判断某字符串是否为空或长度为0或由空白符(whitespace)构成

扫描二维码关注公众号,回复: 4676088 查看本文章

BigDecimal的四则运算方法:

public BigDecimal add(BigDecimal value);                        //加法
public BigDecimal subtract(BigDecimal value);                   //减法 
public BigDecimal multiply(BigDecimal value);                   //乘法
public BigDecimal divide(BigDecimal value);                     //除法

猜你喜欢

转载自www.cnblogs.com/erfsfj-dbc/p/10188131.html