public class Song {
private String title;
private String artist;
private int year;
private String country;
public Song() {}
public Song(int year,String country,String artist,String title) {
this.year = year;
this.country = country;
this.artist = artist;
this.title = title;
}
void show() {
System.out.println(year+"년 "+country+"국적의 "+artist+"가 부른 "+title);
}
public static void main(String[] args) {
// TODO Auto-generated method stub
Song s = new Song(1978,"스웨덴","ABBA","Dancing Queen");
s.show();
}
}
결과
1978년 스웨덴국적의 ABBA가 부른 Dancing Queen
'명품JAVA프로그래밍 > 4장 클래스와 객체' 카테고리의 다른 글
[명품JAVA프로그래밍] 4장 실습문제 5번 (0) | 2021.12.27 |
---|---|
[명품JAVA프로그래밍] 4장 실습문제 4번 (0) | 2021.12.27 |
[명품JAVA프로그래밍] 4장 실습문제 2번 (0) | 2021.12.27 |
[명품JAVA프로그래밍] 4장 실습문제 1번 (0) | 2021.12.27 |
[명품JAVA프로그래밍] 4장 Open Challenge (0) | 2021.12.27 |