Suppose i have the following classes:
And my main classCode:class testA
{
public int myVar = 12;
}
class testB
{
public testA m_testa;
public testB ( testA testa )
{
this.m_testa = testa
}
}
So as you can see i create an instance of classA in my Main class and pass that to classB.Code:class Main
{
public void blaat()
{
testA testa = new testA();
testB testb = new testB(testa);
testa.myVar = 400;
}
}
What happends when i directly change a value of classA from my Main class and after that display that same value from classB..??
Will the instance of classA that is in classB also know about that change or will that one still hold the old value??
If that's the case, how can i make it so that when i change a value of classA from Main that the instance of classA in classB will be exactly the same??