public class TV {
private String brand;
private int year;
private int inch;
public TV(String brand,int year,int inch) {
this.brand = brand;
this.year = year;
this.inch = inch;
}
void show() {
System.out.println(brand+"에서 만든 "+year+"년형 "+inch+"인치 TV");
}
public static void main(String[] args) {
// TODO Auto-generated method stub
TV myTV = new TV("LG",2017,32);
myTV.show();
}
}
결과
LG에서 만든 2017년형 32인치 TV
'명품JAVA프로그래밍 > 4장 클래스와 객체' 카테고리의 다른 글
[명품JAVA프로그래밍] 4장 실습문제 5번 (0) | 2021.12.27 |
---|---|
[명품JAVA프로그래밍] 4장 실습문제 4번 (0) | 2021.12.27 |
[명품JAVA프로그래밍] 4장 실습문제 3번 (0) | 2021.12.27 |
[명품JAVA프로그래밍] 4장 실습문제 2번 (0) | 2021.12.27 |
[명품JAVA프로그래밍] 4장 Open Challenge (0) | 2021.12.27 |