Advertisement
Guest User

Untitled

a guest
Jul 28th, 2015
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. if(listOfWords.contain(word))
  2. write.print(word+" ");
  3. // using this method but it does not work
  4.  
  5. private boolean contain(englishWord list, String word) {
  6. if (list != null) {
  7. contain(list.getLeft(), word);
  8. if (word.equals(list.getWord())) {
  9. return true;
  10. }
  11. contain(list.getRight(), word);
  12. }
  13. return false;
  14. }
  15.  
  16. if (list != null) {
  17. if (word.equals(list.getWord()) || contain(list.getLeft(), word) || contain(list.getRight(), word)) {
  18. return true;
  19. }
  20. }
  21. return false;
  22.  
  23. if (list != null) {
  24. int compare = word.compareTo(list.getWord());
  25. if (compare == 0) {
  26. return true;
  27. } else if (compare > 0) {
  28. return contain(list.getRight(), word);
  29. } else {
  30. return contain(list.getLeft(), word);
  31. }
  32. }
  33. return false;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement