package practice; import java.util.HashSet;import java.util.Iterator; public class HashSetEx5 { public static void main(String[] args) {// TODO Auto-generated method stubHashSet setA = new HashSet();HashSet setB = new HashSet();HashSet setHab = new HashSet();HashSet setKyo = new HashSet();HashSet setCha = new HashSet(); setA.add("1");setA.add("2");setA.add("3");setA.add("4");setA.add("5");System..
package practice; import java.util.Collections;import java.util.HashSet;import java.util.LinkedList;import java.util.List;import java.util.Set; public class HashSetLotto { public static void main(String[] args) {// TODO Auto-generated method stub Set set = new HashSet();// 해쉬셋을 인스턴스로 갖는 셋 참조변수 생성 (다형성) for (int i = 0; set.size() < 6; i++) {int num = (int) (Math.random() * 45) + 1;// 임의의 1~45 사이의..
package practice; import java.util.HashSet;import java.util.Set; public class HashSetEx1 { public static void main(String[] args) {// TODO Auto-generated method stub Object[] objArr = { "1", new Integer(1), "2", "2", "3", "3", "4", "4","4" };Set set = new HashSet(); // 해쉬셋 생성// Set set = new LinkedHashSet(); //해쉬셋 생성(정렬된 데이터) for (int i = 0; i < objArr.length; i++) {set.add(objArr[i]);// 중복되는 값을..
package practice; import java.util.ArrayList;import java.util.Iterator; public class IteratorEx2 { public static void main(String[] args) {// TODO Auto-generated method stubArrayList original = new ArrayList(10);ArrayList copy1 = new ArrayList(10);ArrayList copy2 = new ArrayList(10);// 3개의 Array List 객체 생성 for (int i = 0; i < 10; i++) {original.add(i + "");// 객체 삽입}Iterator it = original.iterato..
package practice; import java.util.ArrayList;import java.util.ListIterator; public class ListIteratorEx1 { public static void main(String[] args) {// TODO Auto-generated method stub ArrayList list = new ArrayList();list.add("1");list.add("2");list.add("3");list.add("4");list.add("5"); ListIterator it = list.listIterator();// 리스트 이터레이터 객체 생성 while (it.hasNext()) {System.out.println(it.next());// ..
package practice; import java.util.ArrayList;import java.util.Iterator; public class IteratorEx1 { public static void main(String[] args) {// TODO Auto-generated method stub ArrayList list = new ArrayList();list.add("1");list.add("2");list.add("3");list.add("4");list.add("5");//ArrayList 생성 및 객체 추가 Iterator it = list.iterator();//이터레이터 생성while (it.hasNext()) {Object obj = it.next(); //다음 객체를 읽음,..
package practice; import java.util.LinkedList;import java.util.Queue;import java.util.Stack; public class StackQueueEx { public static void main(String[] args) {// TODO Auto-generated method stub Stack st = new Stack();Queue q = new LinkedList();// LinkedList는 Queue 인터페이스를 구현하였다. st.push("0");st.push("1");st.push("2");// 스택에 넣기 q.offer("0");q.offer("1");q.offer("2");// 큐에 넣기 System.out.println("..
package practice; import java.util.ArrayList;import java.util.LinkedList;import java.util.List; public class ArrayLinkedListTest { public static void main(String[] args) {// TODO Auto-generated method stub //각각의 삽입, 삭제 메소드의 시간을 측정하는 프로그램ArrayList al = new ArrayList(1000000);LinkedList ll = new LinkedList(); System.out.println("== 순차적으로 추가하기 =="); System.out.println("ArrayList : " + add1(al));Sys..