Variables Name Hiding - Java Object Oriented Design

Java examples for Object Oriented Design:Field

Description

Variables Name Hiding

Demo Code

public class Main {
  int num = 2017; // An instance variable
 
  void printNum(int num) {
    System.out.println("Parameter num: " + num);
    System.out.println("Instance variable num: " + num);
  }/*from  w  w w . ja  v a  2  s. com*/

  public static void main(String[] args) {
    Main a = new Main();
    a.printNum(2000);
  }
}

Result


Related Tutorials