Skip to content

Instantly share code, notes, and snippets.

@javiersantos
Last active August 29, 2015 14:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save javiersantos/58b7aa21338082d6c850 to your computer and use it in GitHub Desktop.
Save javiersantos/58b7aa21338082d6c850 to your computer and use it in GitHub Desktop.
Return the uppercase letters of a string
/*
* 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