DAY 04
✍️ Standard JDK -> %JAVA_HOME%/bin
- jar : .class -> 참조형 / %JAVA_HOME%/lib/rt.jar...
- javadoc : API
- jdb,jdeps : JAVA META_DB
- javah,javap : 역컴파일 하는 모듈
- jar,java,javac,javadoc : 가장 많이 사용
- extcheck, appletviewr : 많이 사용 안함
Security Tools (keytool, jarsigner,policytool,kinit,klist,ktab)
Internationalization Tools (native2ascii)
- 아스키코드로 변환해주는 tool
Java Wep Start Tools (javaws)
Monitoring Tools -> Hadoop 에서 사용
✍️ class
.class -> 자바의 실행단위 -> JVM[byte = stream]
class -> 사용자 자료형을 만드는 키워드 / userName -> 자료형 이름
class userName{
멤버 = 속성 (NESTED|FIELD) + 메소드 (CONSTR|METHOD)
}
✍️ void , return
[형식]
접근제한자 static [void,return data type] userName(args...){
return value;
}
[호출]
datatype 변수 = userName(args...)
ex)
public class Test {
public static char getCh() { // 데이터 타입 하나만 가능하므로 return값도 하나 (,로 나열X)
return 'Z'; // getCH()라는 메소드는 char 2byte 값 'z'를 리턴한다.
//return ('A' +1); // 이거는 가능(연산) /A+1 = B;
}
public static int getA(){
return 100; // getA()라는 메소드는 int 4byte 값 100을 리턴
}
public static double getD(){
return 98.9; // getD()라는 메소드는 double 8byte값 98.9 리턴
}
public static void main(String[] args) {
char ch = getCh(); // char type의 'z'를 리턴하는 메소드
int res = getA(); // int type의 100을 리턴하는 메소드
double d = getD(); //double type의 98.9를 리턴하는 메소드
System.out.println (ch + "\t" + res +"\t" + d); // 'z' 100 98.9
System.out.println (gerCh() + "\t" + getA() +"\t" + getD());
double res02 = getA() + getD(); // double res02 = 100 + 98.9
System.out.println (res02);
}
}
=> void는 리턴이 없다
//java.lang.Math
//java.lang.Integer // 자바의 lang패키지는 import하지 않는다.
public class Test {
public static void Exam01 (int r){
// 반지름 r을 입력 받아 원의 둘레를 구해보자
double res = 2 * r *Math.PI;
System.out.println(res);
}
public static double Exam02 (int r){
// 반지름 r을 입력받아 원의 둘레를 리턴받아보자
double res = 2 * r *Math.PI;
return res;
}
public static void main(String[] args){
Exam01(10);
double res = Exam02(7);
System.out.println(res);
// public static double sqrt(double a) -> double 숫자를 주면 double 값을 리턴하는 static 메소드
double res02 = Math.sqrt(100); // double a = 100; => 자동형변환
System.out.println(res02);
int res03 = (int)Math.sqrt(100); // int res03 = (int)double -> 강제형변환
System.out.println(res03);
}
}
✍️ 자바의 제어문
1. 조건문 및 선택문 : if문, 단일 if~else문, 다중 if~else문, switch~case문
if문 (만일에 ~ 하면)
- 조건식이 true일 경우에만 명령을 수행한다.
if(조건식){
수행할명령;
}
ex) 만일에 입력된 숫자가 양수이면 양수라고 출력하자
int a = 10;
if (a>0){
System.out.println("양수");
}
단일 if~else문
- 조건이 true이면 명령을 수행하고 false이면 else에 있는 명령을 수행한다.
if(조건식){
true명령;
}
else{
false명령;
}
ex) 입력된 숫자가 양수이면 양수라고 출력하고 그렇지 않으면 양수 아니잖아 라고 출력하자
if(a>0){
System.out.println("양수");
}
else{
System.out.println("양수아니잖아");;
}
다중 if~else문
if(조건식1){
true1 명령;
}
else if(조건식2){
true2 명령;
}
else if(조건식3){
true3 명령;
}
else if(조건식4){
true4 명령;
}
else{
false 명령;
}
✏️ jar 파일