Java
public class SpringContextHolder implements ApplicationContextAware {
private static ApplicationContext applicationContext;
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
SpringContextHolder.applicationContext = applicationContext;
}
public static <T> T getBean(Class<T> clazz) {
return applicationContext.getBean(clazz);
}
public static <T> T getBean(String name, Class<T> clazz) {
return applicationContext.getBean(name, clazz);
}
}
String classInfo = "Class=2,Teacher=Lisa,StudentNum=30";
// 该方法按照每单个字符逐个分割
System.out.println(StringUtils.split(classInfo, ",PC")[0]); // lass=2
// 该方法将字符串当成一个整体去分割
System.out.println(StringUtils.splitByWholeSeparator(classInfo, ",PC")[0]); // Class=2,Teacher=Lisa,StudentNum=30
byte[] CSV_BOM_HEADER = new byte[]{(byte) 0xEF, (byte) 0xBB,(byte) 0xBF};
OutputStream out = resp.getOutputStream();
out.write(CSV_BOM_HEADER);
1、使用范围不同:@Resource使用范围是类字段和Setter方法,@Autowired范围更广:类字段、Setter方法、构造方法、方法参;
2、当依赖缺失时,@Resource注入会报错,@Autowired(required=false)可以避免报错;
3、@Resource有属性可以指定依赖的bean名称,@Autowired和@Qulifier也可以达到该效果。
不允许输入 Lemon 完整的字符串,大小写严格
Pattern pattern = Pattern.compile("^(?!Lemon$).+$");
System.out.println(pattern.matcher("Lemon").matches()); // false
System.out.println(pattern.matcher("lemon").matches()); // true
- 非捕获 lambda 表达式的开箱即用性能已经领先于提升的匿名内部类。捕获 lambda 表达式的实现与分配匿名内部类以捕获这些字段的性能类似;
- lambda 表达式是非捕获( lambda 不访问在其主体外部定义的任何变量)还是捕获( lambda 访问在其主体外部定义的变量)
来源:https://javakk.com/2339.html
来源:
- https://segmentfault.com/a/1190000040373647
- https://www.cnblogs.com/share-duke/p/12323576.html