수색…


소개

클래스는 객체의 속성 및 / 또는 동작을 정의하는 코드 조각입니다. 변수, 상수, 메소드 및 생성자를 클래스 내부의 객체에 정의 할 수 있습니다. 즉, 클래스는 객체의 청사진입니다.

자바에서 간단한 클래스를 정의 해보자.

public class Car {
  private Engine engine;
  private Body body;
  private Tire [] tire;
  private Interior interior;

  // Constructor 
  public Car (Engine engine, Body body, Tire[] tires, Interior interior) {
    
  }

  // Another constructor
  public Car () {
    
  }

  public void drive(Direction d) {
    // Method to drive
  }

  public void start(Key key) {
    // Start 
  }
}

이는 단지 예시 일뿐입니다. 당신은 당신의 요구 사항에 따라 이와 같이 실제 세계의 물체를 모델링 할 수 있습니다.



Modified text is an extract of the original Stack Overflow Documentation
아래 라이선스 CC BY-SA 3.0
와 제휴하지 않음 Stack Overflow