Advertisement
SadJest

Untitled

Mar 31st, 2015
235
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. public class Node
  2. {
  3. private String token_;
  4. private Node next_;
  5.  
  6. public Node(String token, Node next){
  7. token_ = token;
  8. next_ = next;
  9. }
  10.  
  11. public void Add(String s){
  12. Node a = new Node(s);
  13. a.next = head;
  14. head = a;
  15. }
  16.  
  17. public int find(String word){
  18. int counter = 0;
  19. Node current = token_;
  20. while(current != null){
  21. if(current.token_ == word){
  22. return counter;
  23. }
  24. else{
  25. current = current.next;
  26. counter++;
  27. }
  28. }
  29. return -1;
  30. }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement