PPT Slide
public class Test {
int x;
static int y = 2;
}//class Test
CLASS
INSTANCES
Test t1 = new Test();
t1.x = 5; // should use accessor
Test t1 = new Test();
t1.x = 3; // should use accessor
public class Test {
int x; // now 5
static int y; // 2
}//class Test
public class Test {
int x; // now 3
static int y; // 2
}//class Test
New class instances (objects) get unique copies
of every member--except for static or “class” members. We can think of static as meaning “only one copy”
int y; // still 2
int y; // still 2
Previous slide
Next slide
Back to first slide
View graphic version