Java examples for Object Oriented Design:Field
Using the Simple Name of an Instance Variable in an Instance Method
public class Main { int num = 2017; // An instance variable void printNum() { System.out.println("Instance variable num: " + num); }/* w w w . j av a 2 s. c om*/ public static void main(String[] args) { Main a = new Main(); a.printNum(); } }