CSC300: Common mistakes: Does this work? [8/10] |
01 |
public int numFives () { if (first == null) return 0; int result = 0; if (first.item == 5.0) result = result + 1; Node x = first; while (x.next != null) { if (x.item == 5.0) result = result + 1; x = x.next; } return result; } |