String类的共享设计模式
- public class TestDemo1
- {
- public static void main(String [] args)
- {
- String s1 = "Hello" ;
- String s2 = "Hello" ;
- System.out.println(s1==s2));
- System.out.println(s1.equals(s2));
- }
- }
运行结果都为true
匿名类
String类的共享设计模式
运行结果都为true
匿名类