SHARE
TWEET

Untitled

a guest Jul 17th, 2017 48 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
Top