Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if(listOfWords.contain(word))
- write.print(word+" ");
- // using this method but it does not work
- private boolean contain(englishWord list, String word) {
- if (list != null) {
- contain(list.getLeft(), word);
- if (word.equals(list.getWord())) {
- return true;
- }
- contain(list.getRight(), word);
- }
- return false;
- }
- if (list != null) {
- if (word.equals(list.getWord()) || contain(list.getLeft(), word) || contain(list.getRight(), word)) {
- return true;
- }
- }
- return false;
- if (list != null) {
- int compare = word.compareTo(list.getWord());
- if (compare == 0) {
- return true;
- } else if (compare > 0) {
- return contain(list.getRight(), word);
- } else {
- return contain(list.getLeft(), word);
- }
- }
- return false;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement