커뮤니티

고용노동부, 산업인력공단과 함께하는 강원도 유일한 기업중심 IT전문교육기관 ICT융합캠퍼스만의 특별한교육입니다.
공인 IT숙련기술인의 다양한 접근방법으로 전문가다운 실무교육을 받을 수 있습니다.

Category

교육강좌

언어 JAVA - 제어문 - 조건문

페이지 정보

작성자 관리자 댓글 0건 조회 2,606회 작성일 20-06-09 11:41

본문

조건문

수업소개

조건에 따라서 다르게 동작하게 프로그램을 디자인하는 핵심은 조건문입니다. 조건문이라는 위대한 도구를 이용해서 우리의 프로그램을 더욱 지능적으로 만들어봅시다. 

 

 

 

강의1

소스코드

변경사항

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
public class IfApp {
public static void main(String[] args) {
System.out.println("a");
if(false) {
System.out.println(1);
} else if(true) {
System.out.println(2);
} else {
System.out.println(3);
}
System.out.println("b");
}
}

 

 

 

강의2

소스코드

변경사항

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
public class AuthApp {
public static void main(String[] args) {
String id = "egoing";
String inputId = args[0];
System.out.println("Hi.");
//if(inputId == id) {
if(inputId.equals(id)) {
System.out.println("Master!");
} else {
System.out.println("Who are you?");
}
}
}

 

 

 

강의3

소스코드

변경사항

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
public class AuthApp {
public static void main(String[] args) {
String id = "egoing";
String inputId = args[0];
String pass = "1111";
String inputPass = args[1];
System.out.println("Hi.");
if(inputId.equals(id) && inputPass.equals(pass)) {
System.out.println("Master!");
} else {
System.out.println("Who are you?");
}
}
}

 

  • 트위터로 보내기
  • 페이스북으로 보내기
  • 구글플러스로 보내기

답변목록

등록된 답변이 없습니다.