HashSet

응용 SoftWare/JAVA 2016. 12. 14. 17:01

import java.util.HashSet;

import java.util.Iterator;


public class HashSetTest {

Double data[] = {23.2, 25.6, 89.6, 56.7, 23.2, 25.6, 89.6, 56.7};

public HashSetTest() {

//중복을 허용하지 않음

HashSet<Double> hs = new HashSet<Double>();

for(int i=0; i<data.length; i++){

hs.add(data[i]);

}

//출력

Iterator<Double> ii = hs.iterator();

while(ii.hasNext()){ //객체가 있는지 확인

System.out.println(ii.next());

}

}


public static void main(String[] args) {

new HashSetTest();


}


}



'응용 SoftWare > JAVA' 카테고리의 다른 글

HashMap  (0) 2016.12.14
TreeSet  (0) 2016.12.14
LinkedList  (0) 2016.12.14
Stack  (0) 2016.12.14
Properties  (0) 2016.12.14
Posted by Hyun CHO
,

LinkedList

응용 SoftWare/JAVA 2016. 12. 14. 17:00

import java.util.LinkedList;


public class LinkedListTest {


public LinkedListTest() {

//LinkedList 컬렉션은 입력 순서대로 출력

//풀력 후 객체는 삭제됨

LinkedList<String> ll = new LinkedList<String>();

ll.offer("이순신");

ll.offer("충무공");

ll.offer("홍길동");

ll.offer("1234");

ll.offer("컬렉션");

//객체 얻어오기

while(ll.size()>0){

System.out.println(ll.pop());

}

}


public static void main(String[] args) {

new LinkedListTest();


}


}



'응용 SoftWare > JAVA' 카테고리의 다른 글

TreeSet  (0) 2016.12.14
HashSet  (0) 2016.12.14
Stack  (0) 2016.12.14
Properties  (0) 2016.12.14
ArrayList  (0) 2016.12.14
Posted by Hyun CHO
,

Stack

응용 SoftWare/JAVA 2016. 12. 14. 17:00

import java.util.Stack;


public class StackTest {


public StackTest() {

Stack<Integer> stack = new Stack<Integer>();

//데이터 추가

stack.push(new Integer(100));

stack.push(new Integer(200));

stack.push(new Integer(300));

stack.push(new Integer(400));

//Stack 컬렉션의 객체 얻어오기

// empty 스택이 비어있는지 확인 후 객체가 없을 때 true

while(!stack.empty()){

System.out.println(stack.pop()); //pop() : 객체 얻어오기

}

}


public static void main(String[] args) {

new StackTest();


}


}



'응용 SoftWare > JAVA' 카테고리의 다른 글

HashSet  (0) 2016.12.14
LinkedList  (0) 2016.12.14
Properties  (0) 2016.12.14
ArrayList  (0) 2016.12.14
[응용] RGB 검색창 (JLabel, JPanel, JSlider)  (0) 2016.12.12
Posted by Hyun CHO
,