Java49 객체지향 프로그래밍 - 객체 지향 구성요소 클래스란?특정 객체 내에 있는 변수와 메서드를 정의하는 일종의 틀하나 이상의 유사한 객체들을 묶어서 하나의 공통된 특성을 표현클래스는 객체의 설계도예시 (클래스 정의)public class Car { // 속성 (필드) String color; String model; int year; // 생성자 public Car(String color, String model, int year) { this.color = color; this.model = model; this.year = year; } // 메서드 public void drive() { System.out.println("The car is driv.. 2024. 5. 30. 이전 1 ··· 6 7 8 9 다음