CSC301: More Size: How is this different? [3/30] Previous pageContentsNext page

public class IntSet {
    private Node root;
    private static class Node {
        public final int key;
        public Node left, right;
        public Node (int key) { this.key = key; }
    int size = 0;
    public int size () {
        for (int x : this.levelOrder ())
       return size;

This now violates yet another criterion of the assignment.

A field is a variable that is declared outside of a method.

Previous pageContentsNext page