[Java Programming] Class와 Object 배우기, 클래스 오브젝트


class Person{

String name;

String bloodType;

}


class Cat{

String name;

}

public class Application{

public static void main(String[] args){

Person person1 = new Person();

person1.name = "Jerry";

person1.bloodType = "A";


Person person2 = new Person();

person2.name = "Jordan";

person2.bloodType = "B";


Cat cat1 = new Cat();

cat1.name = "catty";


System.out.println(person1.name);

System.out.println(cat1.name);

}

}


[result]

jerry

catty



+ Recent posts