Comment Re:The Master Of C (Score 1) 334
Java doesn't work that way. Every "new" invocation would create a new Ball object:
e.g. new Ball("Red"); new Ball("Blue"); would always create two Ball objects.
Perhaps the member variable you used for the colour was a static/class variable?
For instance:
e.g. new Ball("Red"); new Ball("Blue"); would always create two Ball objects.
Perhaps the member variable you used for the colour was a static/class variable?
For instance:
would cause the behaviour you described.class Ball {
static String colour;
Ball(String c)
{
colour = c;
}
.
.
.
}