1.日志时间打印StopWatch
public static void main(String[] args) throws InterruptedException {
StopWatchTest.test1();
}
public static void test1() throws InterruptedException {
StopWatch sw = new StopWatch("test");
sw.start("task1");
// do something
Thread.sleep(100);
sw.stop();
sw.start("task2");
// do something
Thread.sleep(200);
sw.stop();
System.out.println("sw.prettyPrint()~~~~~~~~~~~~~~~~~");
System.out.println(sw.prettyPrint());
}
2.初始化list
ArrayList<T> obj = new ArrayList<T>() {{
add(Object o1);
add(Object o2);
...
...
}};
3.字符串拼接
String content = String.format("%s 您好, 您已重置密码, 默认初始密码为:[%s], 请尽快修改密码", sysUser.getUsername(), "password");
4.判断两个list是否有交集
//存在交集flase//不存在true
boolean isNotAdmin = Collections.disjoint(user.getRoleCodes(), UserConstant.ROLE_CODE_LIST);
if (isNotAdmin){
return R.failed("暂无权限");
}