Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.