Ad
Code
Diff
  • public class AbbreviateTwoWords {
    
      public static String abbrevName(String name) {
        return (name.split(" ")[0].charAt(0) + "." + name.split(" ")[1].charAt(0));
      }
    }
    • public class AbbreviateTwoWords {
    • public static String abbrevName(String name) {
    • String[] names = name.split(" ");
    • return (names[0].charAt(0) + "." + names[1].charAt(0)).toUpperCase();
    • return (name.split(" ")[0].charAt(0) + "." + name.split(" ")[1].charAt(0));
    • }
    • }