[TIL] 항해99 9일차

심우진·2021년 9월 20일
0
post-thumbnail

반복문 - for, 조건문 - 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
    }
}

클래스 - Class

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 Controller - JSON 형식의 자동응답기

RBDMS - 컴퓨터에 정보를 저장하고 관리하는 기술 (MySQL, PostgreSQL, Oracle Database)

JPA - SQL을 쓰지않고 데이터를 생성, 조회, 수정, 삭제 할 수 있도록 해주는 번역기

0개의 댓글