@Test public void testGetLastWord() { assertEquals(getLastWord(null), ""); assertEquals(getLastWord(""), ""); assertEquals(getLastWord("hola"), "hola"); assertEquals(getLastWord("hola adios"), "adios"); assertEquals(getLastWord("hola ."), "."); }
public static String getLastWord(final String sentence) { String word = ""; if (sentence != null) { List<String> words = Arrays.asList(sentence.split(" ")); if (words.size() > 0) { word = words.get(words.size() - 1); } } return word; }
WordUtils { public static String getLastWord(final String sentence) { String word = ""; if (sentence != null) { List<String> words = Arrays.asList(sentence.split(" ")); if (words.size() > 0) { word = words.get(words.size() - 1); } } return word; } }
WordUtils { public static String getLastWord(final String sentence) { String word = ""; if (sentence != null) { List<String> words = Arrays.asList(sentence.split(" ")); if (words.size() > 0) { word = words.get(words.size() - 1); } } return word; }  }
WordUtils { public static String getLastWord(final String sentence) { String word = ""; if (sentence != null) { List<String> words = Arrays.asList(sentence.split(" ")); if (words.size() > 0) { word = words.get(words.size() - 1); } } return word; }  static String getLastWord(final String sentence); static String capitalize(final String str); static boolean isNumber(String word); }
WordUtils { public static String getLastWord(final String sentence) { String word = ""; if (sentence != null) { List<String> words = Arrays.asList(sentence.split(" ")); if (words.size() > 0) { word = words.get(words.size() - 1); } } return word; }  static String getLastWord(final String sentence); static String capitalize(final String str); static boolean isNumber(String word);  }