class Person { int value; Person() { value=0; } } class HelloWorld { public static void main(String[] args) { System.out.println("Hello World"); Person p=new Person(); System.out.println(p.value); //setValue(p,100); HelloWorld h=new HelloWorld(); h.setValue(p,100); System.out.println(p.value); } static void setValue(Person p, int v) { p.value=v; } }
p.value has changed from 0 to 100.