CSC300: Common mistakes: Does this work? [4/10] Previous pageContentsNext page

01
02
03
04
05
06
07
08
09
10
  public int numFives () {
    Node x = first;
    int result = 0;
    while (x != null) {
      if (x.item == 5.0)
        result = result + 1;
      x = x.next; 
    }
    return result;
  }

Previous pageContentsNext page