StringInterner { public static String weakIntern(String sample) { if (sample == null) { return null; } return sample.intern(); }  static String strongIntern(String sample); static String weakIntern(String sample); static String[] internStringsInArray(String[] strings);  }
@Test public void testWeakIntern() { String weakInternLiteralABC = weakIntern("ABC"); String weakInternSubstringABC = weakIntern("ABCDE".substring(0,3)); String weakInternHeapABC = weakIntern(new String("ABC")); assertSame(weakInternLiteralABC, weakInternSubstringABC); assertSame(weakInternLiteralABC, weakInternHeapABC); assertSame(weakInternSubstringABC, weakInternHeapABC); }