경주장
4주차 과제. 제어문(~2/10) 본문
학습할 것(필수)
- 선택문
- 반복문
제어문(controll statement, control flow)
자바 프로그램을 시작하면 존재하는 main( ) 메소드의 { 부터 } 까지 위에서 아래로 실행하는 흐름을 개발자가 원하는 방향으로 바꿀 수 있게 해주는 것
제어문(조건식){
코드 블럭
}
제어문의 종류는 조건문(conditional)과 반복문(iteration)이 있다.
조건문(conditional)
1. if문
if(조건식){
//조건식이 true라면 실행
}
2. if-else문
if(조건식){
//조건식이 true라면 실행
}else{
//조건식이 false라면 실행
}
3. if-else-if-else문
if(조건식1){
//조건식1이 true라면 실행
}else if(조건식2){
//조건식2가 true라면 실행
}else{
//조건식1과 2가 모두 false라면 실행
}
4. switch-case문
String position = "과장";
Switch(position){
case "부장": System.out.println("나는 부장"); break;
case "과장": System.out.println("나는 과장"); break;
case "대리": System.out.println("나는 대리"); break;
default : System.out.println("나는 백수");
}
, 를활용하여 여러개의 변수를 하나의 case로 처리하거나 break를 생각한 fall through 역시 가능하다.
Java 7부터는 String 타입의 변수도 올 수 있다.
반복문(Iteration)
1. for문
for(초기화식; 조건식; 증감식){
//실행문
}
2.for-each 문
for (type var: iterate) {
body-of-loop
}
iterate로 사용할 수 있는 자료형은 루프를 돌릴수 있는 자료형(배열 및 ArrayList 등)만 가능하다.
정확하게는 iterable을 구현한 객체의 경우에만 가능하다.
3. while문
while(조건문){
//반복 구문
}
4. do-while문
do{
//반복 구문
}while(조건문)
일단 반복 구문을 한번은 실행하고 while 조건문을 실행한다.
과제 (옵션)
과제 0. JUnit 5 학습하세요.
☑️ JUnit5 document 읽고 CheetSheet 프로젝트 만들기 완료
https://junit.org/junit5/docs/current/user-guide/#writing-tests
JUnit 5 User Guide
Although the JUnit Jupiter programming model and extension model will not support JUnit 4 features such as Rules and Runners natively, it is not expected that source code maintainers will need to update all of their existing tests, test extensions, and cus
junit.org
과제 1. live-study 대시 보드를 만드는 코드를 작성하세요.
☑️ 완료
과제 2. LinkedList를 구현하세요.
☑️ ListNode 완료
☑️ LinkedList
과제 3. ☑️ Stack을 구현하세요.
과제 4. ☑️ 앞서 만든 ListNode를 사용해서 Stack을 구현하세요.
과제 5. ☐ Queue를 구현하세요.
GitHub - ndy2/live-study-assignment
Contribute to ndy2/live-study-assignment development by creating an account on GitHub.
github.com
'JAVA > whiteship_live-study' 카테고리의 다른 글
5주차 과제: 클래스 #5 나머지! (0) | 2022.02.21 |
---|---|
5주차 과제: 클래스 #5 (~02.15) (0) | 2022.02.08 |
3주차 과제. 연산자(~1/27) (0) | 2022.01.24 |
2주차 과제. 자바의 프리미티브 타입, 변수 그리고 배열(~1/20) (0) | 2022.01.16 |
1주차 과제: JVM은 무엇이며 자바 코드는 어떻게 실행하는 것인가. (0) | 2022.01.06 |