1 2 class T3105r2 { 3 static final String s0001 = "a"; 4 static final String s0002 = s0001 + s0001; 5 static final String s0004 = s0002 + s0002; 6 static final String s0008 = s0004 + s0004; 7 static final String s0010 = s0008 + s0008; 8 static final String s0020 = s0010 + s0010; 9 static final String s0040 = s0020 + s0020; 10 static final String s0080 = s0040 + s0040; 11 static final String s0100 = s0080 + s0080; 12 static final String s0200 = s0100 + s0100; 13 static final String s0400 = s0200 + s0200; 14 static final String s0800 = s0400 + s0400; 15 static final String s1000 = s0800 + s0800; 16 static final String s2000 = s1000 + s1000; 17 static final String s4000 = s2000 + s2000; 18 static final String s8000 = s4000 + s4000; 19 static final String sffff = s8000 + s4000 + s2000 + s1000 20 + s0800 + s0400 + s0200 + s0100 21 + s0080 + s0040 + s0020 + s0010 22 + s0008 + s0004 + s0002 + "b"; 24 static final String toobig = sffff + "c"; 26 public static void main(String [] args) { 27 if (toobig.equals("")) 28 System.out.println("String was lost completely"); 29 else if (toobig.endsWith("b")) 30 System.out.println("String was truncated at 0xffff bytes"); 31 else if (toobig.endsWith("abc")) { 32 String alternate = sffff; 33 alternate += "c"; 34 alternate = alternate.intern(); 35 if (alternate != toobig) 36 System.out.println("String was not interned"); 37 else 38 System.out.println("OK"); 39 } else 40 System.out.println("Unexpected case"); 41 } 42 } 43 | Popular Tags |