Last active
April 18, 2018 17:15
-
-
Save iamcrypticcoder/dbeb1f5d779ab86e8ab8e33b14da905a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class FunctionDemo { | |
static Function<String, String> shortName = (s) -> { | |
if (null == s || s.length() == 0) return "Unknown"; | |
String[] splits = s.split(" "); | |
String ret = splits[0]; | |
if (splits.length >= 2) ret += " " + splits[1].substring(0, 1) + "."; | |
return ret; | |
}; | |
public static void main(String... args) { | |
System.out.println(shortName.apply("Kazi Mahbubur Rahman")); | |
System.out.println(shortName.apply("Adam Smith")); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment