1// my class
2class my_number {
3 // public member variable
4 public int number;
5
6 // default constructor
7 public my_number()
8 {
9 number = 1;
10 }
11}
12// driver function
13class Main{
14 public static void main (String [] arguments)
15 {
16 // creating object
17 my_number object = new my_number();
18
19 // printing before update
20 System.out.println("number = " + object.number);
21 // update function called.
22 update(object);
23 //printing after update.
24 System.out.println("number = " + object.number);
25 }
26 // update function.
27 public static void update( my_number obj ){
28 // increments number variable.
29 obj.number++;
30 }
31}