Class Variable and Instance Variable
When make "Card" class, the width and height is same and common. The pattern and number are different.
class Card {
String pattern;
int number;
static int width = 100;
static int height = 250;
}
Class Variable(static variable, sharing variable)
Common properties all Instances have. ex) width, height
Card.width = 200;
Card.height = 300;
Card c = new Card();
//가능은 하지만 권장하지 않는다
//c.width = 200;
//c.height = 300;
Instance Variable
Individual properties. ex) pattern, number
Card c = new Card();
c.pattern = "HEART";
c.number = 5;
Last updated
Was this helpful?