본문 바로가기
국비교육/JAVA

12월 13일 국비교육 14일차

by Diligejy 2018. 12. 13.

#1

ⓐ 데이터 타입 바이트 값 외우기

ⓑ 지역변수는 반드시 값을 선언해야 한다!
ⓒ static final = 멤버변수 상수

    nonstatic final = 지역변수 상수

ⓓ 


#2

자바의 제어문

ⓐ 조건문 - if, if-else, 다중 if- else


if(조건식) {

조건식이 true이면 명령수행 false이면 수행x

}

ex) 


[형식]

if(true){
    true 명령
} else if{
    true 명령
} else if{
    true 명령
} else if{
    true 명령
} else {
    false 명령
}    


ex) 만일에 숫자(su)가 0보다 크면 양수 그렇지 않으면 음수라고 출력하자


if(su>0) {
    System.out.println("양수");
}else{
    System.out.println("음수);
}


ⓑ 선택문 - switch ~ case

[형식]

switch(변수){  //int + String(jdk 7버전부터
case 값 : 명령;

case 값 : 명령;

} //default, break;

case 뒤의 값은 정렬이 아니라 아무 값이나 넣어도 됨


ex)

int su = 3;

Switch(su){ // int + String(jdk7)

case 3 : 명령1;

case 4 : 명령2;


// su가 3일때 명령1 수행; 명령2 수행;

}


int su = 3;

Switch(su){

case 4 : 명령 1;

case 3 : 명령 2;


// su가 3일 때 명령 2 수행

}


int su = 3;

Switch(su){ // int + String(jdk7)

case 3 : 명령1;

break;

case 4 : 명령2;


// su가 3일때 명령1 수행;

}


ⓒ 반복문 - 입력반복문 : while, do~ while
               출력 반복문 : for, 

ⓓ 제어 키워드 (break ; return; continue;)


#3


Scanner sc = new Scanner(System.in);

int su = sc.nextInt();


#4

The class also provides additional fields and methods for implementing a concrete calendar system outside the package. Those fields and methods are defined as protected.

Like other locale-sensitive classes, Calendar provides a class method, getInstance, for getting a generally useful object of this type. Calendar's getInstancemethod returns a Calendar object whose calendar fields have been initialized with the current date and time:

     Calendar rightNow = Calendar.getInstance();

#5

 abstract class Calendar{

  public static Calendar getInstance(){

  return new GregorianCalendar();

   }

 }

//싱글톤 


GregorianCalendar는 Calendar의 후손 Class


#6

get(Calendar.MONTH) = 12월인데 11월로 표시됨 따라서 1을 더해줘야 함



#7

Calendar.DAY_OF_WEEK =


#8

next() vs nextLine()


http://enter.tistory.com/105

'국비교육 > JAVA' 카테고리의 다른 글

12월 17일 국비교육 16일차  (0) 2018.12.17
12월 14일 국비교육 15일차  (0) 2018.12.14
12월 12일 국비교육 13일차  (0) 2018.12.12
12월 11일 국비교육 12일차  (0) 2018.12.11
국비교육 11일차  (0) 2018.12.10

댓글