Am I correct in saying:
You can only access an object from the method that created it.
For example, this doesn't compile..
Thanks
You can only access an object from the method that created it.
For example, this doesn't compile..
Or am I just being stupidpublic class Test
{
public static void main(String[] args)
{
Car Porsche = new Car();
Porsche.makeNoise();
anotherMethod();
}
static public void anotherMethod()
{
Porsche.makeNoise();
}
}
Thanks