그냥 배우는 언어 기록하는 공간 :D

국비 학원 기록

[03/07] Calendar, substring, import, for문, foreach문, 배열, 개인정보

꾸준히_노력하기 2025. 3. 17. 23:27

[날짜]

<%@ page import=" "@>

// Calendar
Calendar today = null;
today = today.getInstance( );

int year = today.get(Calendar.YEAR);
int month = today.get(Calendar.MONTH) + 1;
int date = today.get(Calendar.DATE);
int dayOfWeek = today.get(Calendar.DAY_OF_WEEK);

 


[생일, 성별, 좋아하는 색깔]

 


 

x.substring(  ,  );

int age = 0;
age = todayYear - birthYear;

if(birthMonth > todayMonth) {
    age = age - 1;
} else(birthMonth == todayMonth && birthDate > todayDate) {
	age = age - 1;
}

 

 

- <td style="background-color: ;"> </td>

 


[주민번호]

 


 

 

 


[반복문]

- for 문

- foreach 문

// for문
for(int i=0; i<x.length; i++) {

}

String[ ] names = { , , , };
System.out.println(names[i]);

// foreach문 | for(임시 변수 : 배열)
for(String s : names) {

}

 


[for문을 이용한 계산]

 


[for문 안에 if문 중첩]

 


[개인정보]

Student[] s = null;

s = new Student[7];

s[0] = new Student();
s[0].no = 1;
s[0].name = "김예진";
s[0].gender = 'F';
s[0].birthYear = 2001;
s[0].height = 158.0;
s[0].isArmy = false;