程序中遇到的小问题整理

1、字符串用"."点号分割,用以下操作

String[] segmentsattr = segments.split("\\."); //以“.”分割

2、数据库类型为number类型,Java获取数据转换成Int类型时:

   List list = query.list();

   int  count = list.get(0);

报了一下错误: java.math.BigDecimal cannot be cast to java.lang.Integer

解决方案:

Listlist = query.list();

int count = 0;

if(null != list && list.size() > 0){

count = Integer.parseInt(list.get(0).toString());

}

return count;

 

}

 

 

猜你喜欢

转载自zhao103804.iteye.com/blog/2257387