day09_TelevisionTest4

육희영·2021년 10월 5일
0
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입니다.

0개의 댓글

관련 채용 정보