본문 바로가기

프로그래밍언어/Java

[자바 기초] 자바 클래스

package com.myspring.week01;

public class Course {
    private String title;
    private String tutor;
    private int days;

    // 기본생성자
    public Course() {

    }
    
    // 생성자
    public Course(String title, String tutor, int days) {
        this.title = title;
        this.tutor = tutor;
        this.days = days;
    }

    // Setter, Getter
    public void setTitle(String title) {
        this.title = title;
    }

    public void setTutor(String tutor) {
        this.tutor = tutor;
    }

    public void setDays(int days) {
        this.days = days;
    }

    public String getTitle() {
        return title;
    }

    public String getTutor() {
        return tutor;
    }

    public int getDays() {
        return days;
    }
}

 

 

'프로그래밍언어 > Java' 카테고리의 다른 글

가변객체와 불변객체  (0) 2023.05.23
자바 어노테이션  (0) 2023.05.21
[Java] Optional이 모길래???  (0) 2023.04.13
자바로 배우는 자료구조  (0) 2023.02.22
프로그래머스 LV.0  (0) 2023.02.17