Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
Tags
- 구조 분해 할당
- 이메일 전송
- nestjs
- javacript
- 화살표 함수
- JSON.stringify
- JavaScript
- 캐러셀
- Mongoose
- DB
- 위크셋
- 로그스태시
- AGGREGATE
- 중첩 구조 분해
- 자바스크립트
- nextjs
- 참조에 의한 객체 복사
- context switch
- 카카오 소셜로그인
- logstash
- nodemailer
- MongoDB
- react-slick
- nest
- JSON.parse
- TypeScript
- 객체
- 카카오로그인
- 위크맵
- Map
Archives
- Today
- Total
뚜sh뚜sh
반복문과 선택문 본문
반복문
- for 문
package first;
public class test {
public static void main(String[] args) {
// TODO Auto-generated method stub
for (int i=0; i<3; i++) {
System.out.println("hihihi");
}
}
}
- while 문
package first;
public class test {
public static void main(String[] args) {
// TODO Auto-generated method stub
int i = 0;
while(i < 3) {
System.out.println("hihihi");
i++;
}
}
}
- do ~ while 문 -> 사용 빈도 낮음
package first;
public class test {
public static void main(String[] args) {
// TODO Auto-generated method stub
do {
System.out.println("ㅎㅎ");
} while(false);
}
}
선택문
- if ~ else 또는 switch문이 있으며 형식과 사용방법이 C언어와 동일
1. if ~ else
package first;
public class test {
public static void main(String[] args) {
// TODO Auto-generated method stub
int nVar2 = 12;
if (nVar2 < 20) {
System.out.println("hihi");
} else {
System.out.println("xxxx");
}
}
}
2. switch 문
package first;
public class test {
public static void main(String[] args) {
// TODO Auto-generated method stub
int nVar2 = 2;
char cVar = 'a';
switch(cVar) {
case 1:
System.out.println("1");
break;
case 2:
System.out.println("22");
break;
default:
System.out.println("없");
break;
}
}
}
break, continue
- continue
package first;
public class test {
public static void main(String[] args) {
// TODO Auto-generated method stub
for (int i = 0; i < 5; i++) {
if (i == 3) {
continue;
}
System.out.println(i);
}
}
}
- break : 가장 가까운 반복문을 빠져나가게 하는 기능
package first;
public class test {
public static void main(String[] args) {
// TODO Auto-generated method stub
int i = 0;
OUT : while(true) {
while(true) {
i++;
if (i == 3) {
System.out.println("hihi");
break OUT;
} else {
System.out.println(i);
}
}
}
}
}
Comments