<<< Local Attributes     Index     Object Attributes >>>

4. Method scope and attribute names

  • Consider:

    
    public class Number {
        public void method1() {
            int count;
        }
        public void method2() {
            int count;
        }
    }
    
    
  • The code in this example is legal and correct.

  • Actual names of integer variables inside method1 and method2 are unimportant, because the same thread of execution can enter either of methods, but not both at the same time.

    • Note: the above is true if method1 invokes method2 or vice versa.

<<< Local Attributes     Index     Object Attributes >>>