1.判断数组是否包含某值
Arrays.asList(arr).contains(str);
2.循环内部删除元素
Iterator<String> iterator=list.iterator();
while(iterator.hasNext()){
String str=iterator.next();
if("a".equals(str)){
iterator.remove();
}
}
3.Collections.reverse(list); 实现list集合逆序排列
4.double的计算不精确,会有类似0.0000000000000002的误差,正确的方法是使用BigDecimal或者用整型
5.之前数据库使用的是long类型,但是出现出入数据库正常,查询返回给前端后后两位变为0的情况,导致不正确.
js支持的最大整数是2的53次方减1,所以损失了精度;
解决办法:
1.取出后返回前端前转为String类型
2.加@JsonSerialize(using = JsonLongSerializer.class )注解
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;
import java.io.IOException;
public class JsonLongSerializer extends JsonSerializer<Long> {
@Override
public void serialize(Long aLong, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException {
jsonGenerator.writeString(Long.toString(aLong));
}
}
6.
SQL语句的执行顺序:
(5)SELECT (6)DISTINCT < select list >
(1)FROM < table source >
(2)WHERE < condition >
(3)GROUP BY < group by list >
(4)HAVING < having condition >
(7) ORDER BY < order by list >