Instance1 인스턴스 생성과 정적 팩토리 메서드 인스턴스 생성자바에서 객체를 생성하는 기본적인 방법은 new 키워드를 사용하여 생성자를 호출하는 방식가장 직관적이고 간단한 방법예시public class Car { private String model; private int year; // 생성자 public Car(String model, int year) { this.model = model; this.year = year; } public void displayInfo() { System.out.println("Model: " + model + ", Year: " + year); }}// 인스턴스 생성public class Main { public static void.. 2024. 3. 25. 이전 1 다음