Menu



Manage

Cord > Study_JAVA 전체 다운로드
파일 목록
Study_JAVA > 7/CarEx.java Lines 21 | 588 바이트
다운로드

                        package week7;

public class CarEx {
	public static void main(String[] args) {
		//객체를 생성해야 필드에 접근 가능
		Car myCar = new Car();
		
		//필드 값 읽기 ㄱㄴ
		System.out.println("Brand : "+myCar.company);
		System.out.println("model : "+myCar.model);
		System.out.println("Color : "+myCar.color);
		System.out.println("Max Speed : "+myCar.maxSpeed);
		System.out.println("Now Speed : "+myCar.speed);
		
		//필드 값 변경하기
		myCar.speed = 60;
		System.out.println();
		System.out.println("fixed Now Speed : " + myCar.speed);
	}
}