Created
September 2, 2013 12:37
-
-
Save khannedy/6412416 to your computer and use it in GitHub Desktop.
NameHelper.getLastName
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
package com.wordpress.eecchhoo.javaholic.helper; | |
/** | |
* @author Eko Khannedy | |
*/ | |
public class NameHelper { | |
/** | |
* Get last name from full name, if full name is | |
* Eko Khannedy, then last name is Khannedy. | |
* | |
* @param name full name | |
* @return String of last name | |
*/ | |
public static String getLastName(String name) { | |
if (name == null) { | |
return null; | |
} | |
String[] split = name.split(" "); | |
if (split.length < 2) { | |
return null; | |
} | |
return split[split.length - 1]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment