개주 훈련일지/🏋️ 전집중 호흡 훈련

어레이리스트 / 셋 / 맵 사용하기

lshfood2 2025. 10. 22. 17:06

[ArrayList]

ArrayList<Integer> al1 = new ArrayList<>();

ArrayList<Student> datas = new ArrayList<>();

제네릭 선언하고 생성하기!

 

호출은 아래와 같이

al1.add(10);

System.out.println(al);

datas.add(new Student(1001,"티모",90));

 

[Set]

Set<Integer> set = new HashSet<>();

제니릭 선언하고 Hash추가하기

(추상클래스라 객체생성불가 이슈)

 

호출은 아래와 같이

set.add(10);

System.out.println(set);

 

[Map]

Map<Integer,String> map = new HashMap<>();

제니릭 선언하고 Hash추가하기

(추상클래스라 객체생성불가 이슈)

만약 key,value가 다른 자료형이면 제네릭 2개 기입

 

호출은 아래와 같이

map.put(1001, "apple");

System.out.println(map.get(1001));