Created
November 27, 2018 20:29
-
-
Save CompSciRocks/6d6ba92c8cea7d2bd105459b6bc0370a to your computer and use it in GitHub Desktop.
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 int numWordsOfLength( int len ) { | |
int cnt = 0; | |
for (Object w: myList) { | |
String s = (String)w; | |
if (s.length() == len) { | |
cnt++; | |
} | |
} | |
return cnt; | |
} |
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 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