an explanation for a question at examulator had this quote - "If an object is passed to a method, changes to its variables will be valid wherever the class is visible." ... but there are situations aren't there, where a change is not visible? if the object is passed to the method, but the change is made to the variable not via the "." way of refering to it?
so in the following code snippet, in the deduct() method, the reference to balance is via a.balance .... and the change is visible later, but if the reference to balance variable was just "balance" and not "a.balance", the change would NOT be visible outside the deduct() method?
public void Go(){
Account personal = new Account();
personal.rate=7;
Account business = new Account();
business.rate =5;
deduct(business);
System.out.println(business.balance);
System.out.println(personal.rate);
}
public void deduct(Account a){
a.balance=200;
}
}
class Account{
static int rate;
public int balance=100;
thanks
