CSC300: Common mistakes: Does this work? [10/10] Previous pageContents

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

Previous pageContents