the thing to see here is that at the line : String s = new Elm().getTree(); this is the Tree getTree() method that is called (since the Elm class has no getTree() method). In that case, it means you are using the Tree part of the Elm object created on the line above. This Tree part doesn't know its enclosing part, the Elm part with another static variable named "tree". The Tree part works on its own. So, when the Tree.getTree() method is invoked, it accesses the Tree.tree static variable, and the program outputs "tree".