Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@CompSciRocks
Created November 27, 2018 20:29
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 CompSciRocks/6d6ba92c8cea7d2bd105459b6bc0370a to your computer and use it in GitHub Desktop.
Save CompSciRocks/6d6ba92c8cea7d2bd105459b6bc0370a to your computer and use it in GitHub Desktop.
public int numWordsOfLength( int len ) {
int cnt = 0;
for (Object w: myList) {
String s = (String)w;
if (s.length() == len) {
cnt++;
}
}
return cnt;
}
public void removeWordsOfLength( int len ) {
for (int i=myList.size() - 1; i>=0; i--) {
String s = (String)myList.get(i);
if (s.length() == len) {
myList.remove(i);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment