LinkedList Example
public class LinkedListExample { public static void main(String[] args){ //LinkedList => LinkedListLinkedList linkedList = new LinkedList (); linkedList.add(new Connection()); linkedList.add(new Connection("turtle",false)); for (int i =0; i itr = linkedList.iterator(); while (itr.hasNext()) { Connection conn = itr.next(); System.out.println("itr : "+conn.toString()); } System.out.println("before : "+linkedList.size()); System.out.println(linkedList.poll().toString()); System.out.println(linkedList.poll()); System.out.println("after : "+linkedList.size()); } } @ToString @Getter @Setter class Connection { private String name; private boolean isConnection; public Connection() { // TODO Auto-generated constructor stub this("test",true); } public Connection(String nm, boolean conn) { name = nm; isConnection =conn; } }
============================================================================
result :
0: Connection(name=test, isConnection=true) 1: Connection(name=turtle, isConnection=false) itr : Connection(name=test, isConnection=true) itr : Connection(name=turtle, isConnection=false) before : 2 Connection(name=test, isConnection=true) Connection(name=turtle, isConnection=false) after : 0
lombok(Jar)URL: http://ask39.blogspot.kr/2015/10/eclipse-lombok.html