//数组转Sting。 list的话先转成数组在调用该方法
StringUtils.join(sqls.get(key).toArray(), ",")
//json相关JSONOBject和JSON引入的包是com.alibaba.fastjson.JSONObject
//将字符串json转换成json对象
JSONObject json = JSON.parseObject(selection);
String colType = json.getString("colType");
//isBlank方法
作用及用法:Checks if a CharSequence is whitespace, empty ("") or null.
StringUtils.isBlank(null) = true
StringUtils.isBlank("") = true
StringUtils.isBlank(" ") = true
StringUtils.isBlank("bob") = false
StringUtils.isBlank(" bob ") = false
//实例
if (StringUtils.isBlank(colType)) {
colType = search.getColType();
}
//将两个数组合并成一个数组Arrayutils的包是org.apache.commons.lang3.ArrayUtils
ArrayUtils.addAll(数组1, 数组2)
//数组转list
String[] col = mainDto.getExtendCols().split(",");
List<String> extendCol = new ArrayList<String>();
Collections.addAll(extendCol, col);
// 将List转换成逗号隔开的字符串
mainDic.setExtendCols(extendCol.toString().replaceAll("^\\[| |\\]$", ""));
1.Integer转换成int的方法
Integer i = new Integer(10);
int k = i.intValue();
即Integer.intValue();
2.int转换成Integer
int i = 10;
Integer it = new Integer(i);
3.String转换成int的方法
String str = "10";
Integer it = new Interger(str);
int i = it.intValue();
即:int i = Integer.intValue(string);
4.int转换成String
int i = 10;
(1)String s = String.valueOf(i);
(2)String s = Ingeger.toString(i);
(3)String s = "" + i;
5.String转换成Integer
String str = "10";
Integer it = Integer.valueOf(str);
6.Integer转换成String
Integer it = new Integer(10);
String str = it.toString();
一些类型转换小方法
最新推荐文章于 2022-09-22 09:28:06 发布