method는 T가 메소드가 호출될 때 결정됩니다.
( class는 T가 인스턴스 생성시에 결정됩니다)
public static void main(String[] args) {
Box box1 = new Box<>();
box1.set(24);
Box box2 = new Box<>();
box2.set("Poly");
if(compBox(box1, 25))
System.out.println("상자 안에 25 저장");
if(compBox(box2, "Moly"))
System.out.println("상자 안에 Moly 저장");
System.out.println(box1.get());
System.out.println(box2.get());
}
24
Poly
package Hw0806;
class Box<T>{
private T t;
public void set(T t) {
this.t=t;
}
public T get() {
return t;
}
}
public class BoxMain {
private static <T> boolean compBox(Box<T> n1, T n2) {
if (n1.get().equals (n2)) {
return true;
} else
return false;
}
public static void main(String[] args) {
Box<Integer> box1 = new Box<>();
box1.set(24);
Box<String> box2 = new Box<>();
box2.set("Poly");
if (compBox(box1, 25))
System.out.println("상자 안에 25 저장");
if (compBox(box2, "Moly"))
System.out.println("상자 안에 Moly 저장");
System.out.println(box1.get());
System.out.println(box2.get());
}
}
자료구조 및 알고리즘을 구현해 놓은 일종의 라이브러리로 데이터(자바에선 객체)들을 효율적으로 관리하기 위한 방법입니다.
제네릭 기반으로 구현이 되어있습니다.

package Hw0806;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class ArrayMain {
public static void main(String[] args) {
List<Integer> list = new ArrayList<>();
int max = 0;
int i = 0;
while (true) {
Scanner sc = new Scanner(System.in);
System.out.print("정수 입력 >> ");
list.add(sc.nextInt());
if (max < list.get(i)) {
max = list.get(i);
}
if (list.get(i++) < 0) {
System.out.println("음수 입력되어서 종료합니다");
break;
}
}
System.out.println(max);
}
}
Box<String> sbox = BoxFactory.<String>makeBox2("sweet"); System.out.println(sbox.get()); Box<Integer> ibox = BoxFactory.<Integer>makeBox2(1); System.out.println(ibox.get()); Integer i = BoxFactory.<Integer>makeBox3(1); System.out.println(i); //출력 1 Double d = BoxFactory.<Double>makeBox3(2.0); System.out.println(d); //출력 2.0
package Hw0806;
class Box<T> {
private T t;
public void set(T t) {
this.t = t;
}
public T get() {
return t;
}
}
class BoxFactory {
public static <T> Box<T> makeBox2(T t) {
Box<T> box = new Box<T>();
box.set(t);
return box;
}
public static <T> T makeBox3(T t) {
return t;
}
}
public class BoxGeneric {
public static void main(String[] args) {
Box<String> sbox = BoxFactory.<String>makeBox2("sweet");
System.out.println(sbox.get());
Box<Integer> ibox = BoxFactory.<Integer>makeBox2(1);
System.out.println(ibox.get());
Integer i = BoxFactory.<Integer>makeBox3(1);
System.out.println(i);
Double d = BoxFactory.<Double>makeBox3(2.0);
System.out.println(d);
}
}
1.사원들이 소속되어 있는 부서의 번호를 출력하는 쿼리문(중복제거)
select DISTINCT deptno from emp;
2.사원들의 이름을 출력하되, 컬럼이름을 한글로 사원이름 으로 나오게 하시오.
select ename as "사원이름" from emp;
3.월급에 10% 보나스 컬럼이 나오게 출력하시오.
select ename, sal,(sal+(sal*0.1))as"보너스" from emp;
4.dual 이란?
한행 결과를 출력하는 테이블입니다.
5.34.5678 에서 소수 3번째 자리에서 반올림 하여 출력하시오.
SELECT 34.5678, ROUND(34.5678,2) FROM EMP;
6.나누기 연산을 한 후 나머지를 결과로 되돌려주는 함수는?
mod
7.안녕하세요 메롱님 에서 '세요 메롱'을 뽑아 내시오.
select substr('안녕하세요 메롱님',4,5)from dual;
8. comm 이 not null 인 사원들을 comm 순으로 나오게 하시오
select*from emp where comm is not null order by comm;
9.부서번호가 20번인 사원을 월급순으로 출력하시오.
select*from emp where deptno=20 order by sal asc;
10.가장 최근에 입사한 사원부터 출력하는 쿼리문
select*from emp order by hiredate desc;
11.커미션(COMM)을 받지 않는 사원을 검색하는 쿼리문
select*from emp where comm is null;
12.2번째 글자가 A인 사원을 찾는 쿼리문
select*from emp where ename Like '_A%';
13.위치 상관 없이 이름 중에 A가 들어있는 사람을 찾는 쿼리문
select*from emp where ename Like '%A%';