172.16.0.151_20200827-陈政平
问题
-
三种字符串的拼接和使用“+”号进行字符串的拼接的区别?
-
好多有关字符串的方法使用起来容易混淆,需要大量的练习
public class Test { // 抑制编译器警告
@SuppressWarnings("deprecation")
public static void main(String[] args) {
Integer x = 100 ; // Integer.valueOf( 100 )
// 默认是遇到[ -128 , 127 ] 数值时就从缓存中直接获取而不创建新对象
Integer y = Integer.valueOf( 100 );
Integer z = new Integer( 100 ); // JDK 9 已经废弃这类构造,建议使用 valueOf方法
System.out.println( x == y ); // true
System.out.println( x == z ); // false
}
}// 默认是遇到[ -128 , 127 ] 数值时就从缓存中直接获取而不创建新对象
Integer y = Integer.valueOf( 100 );从缓存中直接获取,这里的“缓存”指的是什么?
吐槽
教室里有点热
点赞