[TIL]航海99日目


条件文-if

public class prac {
public static int countFruit(String fruit) {
    List<String> fruits = new ArrayList<>();
    fruits.add("감");
    fruits.add("배");
    fruits.add("감");
    fruits.add("딸기");
    fruits.add("수박");
    fruits.add("메론");
    fruits.add("수박");
    fruits.add("딸기");
    fruits.add("메론");
    fruits.add("수박");
    fruits.add("메론");
    fruits.add("수박");
    fruits.add("감");
    int cnt = 0;
    for (int i=0; i<fruits.size(); i++) {
        String f = fruits.get(i);
        if (fruit == f ) {
            cnt++;
        }
    }
    return cnt;
}
public static void main(String[] args) {
    int gam = countFruit("감");
    System.out.println(gam); // 3
    }
}

クラス-クラス


public class prac {
public static void main(String[] args) {
    String title = "웹개발의 봄, Spring";
    String tutor = "남병관";
    int days = 35;
    Course course = new Course(title, tutor, days);

    System.out.println(course.title);
    System.out.println(course.tutor);
    System.out.println(course.days);
    }
}
public class Course {
    public String title;
    public String tutor;
    public int days;

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

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

Getter-情報を取得する方法;Setter-情報を置換する方法


public class prac {
public static void main(String[] args) {
    String title = "웹개발의 봄, Spring";
    String tutor = "남병관";
    int days = 35;
    Course course = new Course(title, tutor, days);

    course.setTitle(title);
    course.setTutor(tutor);
    course.setDays(days);

    System.out.println(course.getTitle());
    System.out.println(course.getTutor());
    System.out.println(course.getDays());

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

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

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

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

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

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

// Getter
public String getTitle() {
    return this.title;
}

public String getTutor() {
    return this.tutor;
}

public int getDays() {
    return this.days;
}
}

Rest Control-JSON形式の自動応答器


RBDMS:コンピュータに情報を格納および管理する技術(MySQL、PostgreSQL、Oracleデータベース)


JPA-SQL翻訳機