Last active
August 29, 2015 14:08
-
-
Save javiersantos/58b7aa21338082d6c850 to your computer and use it in GitHub Desktop.
Return the uppercase letters of a string
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
/* | |
* Return the uppercase letters of a string. Useful to return an acronym. | |
* By Javier Santos | |
* https://gist.github.com/javiersantos/58b7aa21338082d6c850 | |
*/ | |
public String getUppercase(String str) { | |
String res = ""; | |
String[] split = str.split(" "); | |
for(int i=0; i<=split.length-1; i++){ | |
String auxStr = split[i].trim(); | |
if(Character.isUpperCase(auxStr.charAt(0))){ | |
char aux = auxStr.charAt(0); | |
res = res + aux + ", "; | |
} | |
} | |
return res; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment