1 2 3 4 5 6 7 8 9 10 11 12 13 14
|
String s1 = "Hello";
String s2 = "Hello";
String s3 = "Hell"+"o";
String s4 = new String("Hello");
String s5 = new StringBuilder().append(s1).toString();
char[] tableau = {'H','e','l','l','o'};
String s6 = new String(tableau);
System.out.printf("String '%s' at address 0x%X\n",s1,System.identityHashCode(s1));
System.out.printf("String '%s' at address 0x%X\n",s2,System.identityHashCode(s2));
System.out.printf("String '%s' at address 0x%X\n",s3,System.identityHashCode(s3));
System.out.printf("String '%s' at address 0x%X\n",s4,System.identityHashCode(s4));
System.out.printf("String '%s' at address 0x%X\n",s5,System.identityHashCode(s5));
System.out.printf("String '%s' at address 0x%X\n",s6,System.identityHashCode(s6)); |
Partager