Ad
Code
Diff
  • public class AbbreviateTwoWords {
    
      public static String abbrevName(String name) {
       
        return name.replaceAll("[^A-Z\\s]","").replaceAll("\\s",".");
      }
    }
    • 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.replaceAll("[^A-Z\\s]","").replaceAll("\\s",".");
    • }
    • }