目录
1、字符串切割
字符串切割
String[] split = StringUtils.split(str, "@"); // str按@切割,返回一个split字符串数组
逗号分隔的字符串切割并转为字符串列表:
List<String> strList = Splitter.on(",").trimResults().splitToList(str);
2、字符串包含
检查字符串中是否包含@:
if(StringUtils.contains(str, "@")) {}
3、字符串长度
判断字符串长度:
if(str.length != 1) {}
4、检查是否为空
字符串是否为空
if (StringUtils.isEmpty(str)){}
检查列表是否为空
if(CollectionUtils.isEmpty(strList)) {}
5、遍历
便历字符串列表
for (String str : strList) {}
数字遍历
for (int i = 0; i < num; i++) {}
6、创建
创建List
创建一个 String 类型的列表
List<JSONObject> result = Lists.newArrayList();
创建HashMap
Map<String, Boolean> m = Maps.newHashMap();
LinkedHashMap
Map<String, Object> m = Maps.newLinkedHashMap();
ConcurrentMap
map的key为字符串,map的value为String类型的列表:
Map<String, List<String>> m = Maps.newConcurrentMap();