Developer 지식
                
              Sample code in object and Instance.
                윤태영(Coding)
                 2023. 4. 2. 08:51
              
                          
            Sample code in object and Instance.
//Object definition example code.
class Car {
    private String make;
    private String model;
    
    public Car(String make, String model) {
        this.make = make;
        this.model = model;
    }
    
    public String getMake() {
        return make;
    }
    
    public String getModel() {
        return model;
    }
}
// 인스턴스 생성
Car myCar = new Car("Toyota", "Camry");
// 인스턴스 속성 출력
System.out.println(myCar.getMake()); // Toyota
System.out.println(myCar.getModel()); // Camry