package day09;
public class TelevisionTest4 {
public static void main(String[] args) {
Television3 myTv = new Television3();
myTv.setChannel(11);
int ch = myTv.getChannel();
System.out.println("현재 채널은 " + ch + "입니다.");
}
}
class Television3 {
int channel; // 채널 번호
int getChannel() {
return channel;
}
//방법1
// int setChannel(int x) {
// channel = x;
// return channel;
// }
// 방법2
void setChannel(int ch) {
channel = ch;
}
}
현재 채널은 11입니다.