Advertisement
Guest User

Untitled

a guest
Jul 17th, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. public int positionOfFirstFiveFromBeginning(){
  2. int result = 0;
  3. if(first == null){
  4. return -1;
  5. }
  6. Node x = first;
  7. while(x != null){
  8. if(x.item == 5.0){
  9. return result;
  10. }
  11. result++;
  12. x = x.next;
  13. }
  14. return result;
  15. }
  16.  
  17. public int positionOfFirstFiveFromBeginning(){
  18. int result = 0;
  19. if(first == null || first.item != 5.0){
  20. return -1;
  21. }
  22. Node x = first;
  23. while(x != null){
  24. if(x.item == 5.0){
  25. return result;
  26. }
  27. result++;
  28. x = x.next;
  29. }
  30. return result;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement