최's 먹공로그
JAVA기본_if문 본문
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
31
32
33
34
35
36
37
38
39
40 |
package org.opentutorials.javatutorials.if_statement;
public class if_statement {
public static void main(String[] args) {
if(false) {
System.out.println("result : true");
}
else {
System.out.println("result : false");
}
if(false) {
System.out.println(1);
System.out.println(2);
System.out.println(3);
System.out.println(4);
}
else if (true) {
System.out.println(5);
}
else if (true) {
System.out.println(6);
}
else {
System.out.println(7);
}
if(false) {
System.out.println(1);
System.out.println(2);
System.out.println(3);
System.out.println(4);
}
System.out.println(5);
}
}
|
cs |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 |
package org.opentutorials.javatutorials.if_statement;
public class if_statement2 {
public static void main(String[] args) {
String id = args[0];
String pw = args[1];
if(id.equals("egoing")){
if(pw.equals("111")) { // id가 egoing 이고 pw가 111이면 right 출력 if(id.equals("egoing") && pw.equals("111") 로도 변경 가능
System.out.println("right");
} else {
System.out.println("wrong");
}
} else {
System.out.println("wrong");
}
}
}
|
cs |
'JAVA' 카테고리의 다른 글
JAVA기본_String (0) | 2018.12.31 |
---|---|
JAVA기본_연산자 (0) | 2018.12.31 |
JAVA기본_데이터 타입 (0) | 2018.12.31 |
JAVA기본_주석 (0) | 2018.12.31 |
JAVA기본_비교와 Boolean (0) | 2018.12.31 |