public class Test {
public static void main(String[] args) {
Person p=new Person();
p.setAge(18);
Test t=new Test();
t.changeAge(p);
System.out.println(p.getAge());
}
public Person changeAge(Person p){
p.setAge(100);
return p;
}
}
class Person{
private String name;
private int age ;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
} |