Listing 1. Imperative processing from http://www.ibm.com/developerworks/java/library/j-jn10/index.html
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 TheCompanyProcess { | |
public String cleanNames(List<String> listOfNames) { | |
StringBuilder result = new StringBuilder(); | |
for(int i = 0; i < listOfNames.size(); i++) { | |
if (listOfNames.get(i).length() > 1) { | |
result.append(capitalizeString(listOfNames.get(i))).append(","); | |
} | |
} | |
return result.substring(0, result.length() - 1).toString(); | |
} | |
public String capitalizeString(String s) { | |
return s.substring(0, 1).toUpperCase() + s.substring(1, s.length()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment