@Test public void testSubtractPrefix() throws Exception { Assert.assertEquals("ANA", CharSequences.subtractPrefix("BANANA", "BAN")); Assert.assertEquals("", CharSequences.subtractPrefix("BANANA", "BANANA")); Assert.assertEquals("", CharSequences.subtractPrefix("BANANA", "BANANAS")); Assert.assertEquals("BANANA", CharSequences.subtractPrefix("BANANA", "")); Assert.assertEquals("", CharSequences.subtractPrefix("", "BANANAS")); }
public static CharSequence subtractPrefix(CharSequence main, CharSequence prefix) { int startIndex = prefix.length(); int mainLength = main.length(); if (startIndex > mainLength) { return ""; } return main.subSequence(startIndex, mainLength); }
CharSequences { public static CharSequence subtractPrefix(CharSequence main, CharSequence prefix) { int startIndex = prefix.length(); int mainLength = main.length(); if (startIndex > mainLength) { return ""; } return main.subSequence(startIndex, mainLength); } }
CharSequences { public static CharSequence subtractPrefix(CharSequence main, CharSequence prefix) { int startIndex = prefix.length(); int mainLength = main.length(); if (startIndex > mainLength) { return ""; } return main.subSequence(startIndex, mainLength); } CharSequences(); }
CharSequences { public static CharSequence subtractPrefix(CharSequence main, CharSequence prefix) { int startIndex = prefix.length(); int mainLength = main.length(); if (startIndex > mainLength) { return ""; } return main.subSequence(startIndex, mainLength); } CharSequences(); static Iterable<CharSequence> generateSuffixes(final CharSequence input); static Iterable<CharSequence> generatePrefixes(final CharSequence input); static CharSequence getCommonPrefix(CharSequence first, CharSequence second); static CharSequence getSuffix(CharSequence input, int startIndex); static CharSequence getPrefix(CharSequence input, int endIndex); static CharSequence subtractPrefix(CharSequence main, CharSequence prefix); static CharSequence concatenate(final CharSequence first, final CharSequence second); static CharSequence reverse(CharSequence input); static CharSequence fromCharArray(final char[] characters); static char[] toCharArray(CharSequence charSequence); static String toString(CharSequence charSequence); }
CharSequences { public static CharSequence subtractPrefix(CharSequence main, CharSequence prefix) { int startIndex = prefix.length(); int mainLength = main.length(); if (startIndex > mainLength) { return ""; } return main.subSequence(startIndex, mainLength); } CharSequences(); static Iterable<CharSequence> generateSuffixes(final CharSequence input); static Iterable<CharSequence> generatePrefixes(final CharSequence input); static CharSequence getCommonPrefix(CharSequence first, CharSequence second); static CharSequence getSuffix(CharSequence input, int startIndex); static CharSequence getPrefix(CharSequence input, int endIndex); static CharSequence subtractPrefix(CharSequence main, CharSequence prefix); static CharSequence concatenate(final CharSequence first, final CharSequence second); static CharSequence reverse(CharSequence input); static CharSequence fromCharArray(final char[] characters); static char[] toCharArray(CharSequence charSequence); static String toString(CharSequence charSequence);  }