Java examples for Object Oriented Design:Field
Using the this Keyword to Refer to an Instance Variable Whose Name Is Hidden by a Local Variable
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: " + this.num); }/*from ww w .j a v a 2 s . c om*/ public static void main(String[] args) { Main a = new Main(); a.printNum(2000); } }