2023-02-16 목
<Eclipse>
● 삼항연산자
- (조건식 ? A : B)
- if else if 의 또다른 표현법
● swich
- which(A) {
case(a) ~~
break
case(b) ~~
break
● for
- 구구단
for (int i=1; i<10; i++) {
System.out.println( " "+i + "단");
for(int j=1; j<10; j++) {
System.out.println(i + "x" + j + " = " + i*j);
}
System.out.println("------------");
}
- 별표 증감소
for(int i=1; i<10; i++) {
for(int j=1; j<10; j++) {
System.out.print("*");
}
System.out.println();
}
System.out.println("--------------");
for(int i=1; i<10; i++) {
for(int j=1; j<=i; j++) {
System.out.print("*");
}
System.out.println();
}
System.out.println("--------------");
for(int i=1; i<10; i++) {
for(int j=i; j<10; j++) {
System.out.print("*");
}
System.out.println();
}
● 랜덤값 생성
- (Math.random()*20)+1 → 1부터 20개의 랜덤값 생성
● 스캐너 입력
- Scanner a = new Scanner(System.in)
- 스캐너 객체 a 생성
'JAVA(복습)' 카테고리의 다른 글
2023-02-27(월) cookie , session (0) | 2023.02.27 |
---|---|
2023-02-20(월) Servlet , 톰캣 , 객체 , 클래스 , 상속 , 오버라이딩 (0) | 2023.02.20 |
2023-02-17 (금) FirstServlet , web.mxl , index.html , FirstPage , 맵핑 (0) | 2023.02.17 |