LinkedList Example

public class LinkedListExample {
 public static void main(String[] args){
  //LinkedList => LinkedList
  LinkedList 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

Popular posts from this blog

youtube download

com.gpki.secureweb.GPKISecureWEBException: ErrCode=1507,ErrMsg=[GPKI_CMS_ProcessEnvelopedData] 해당 인증서로는 데이터를 풀 수 없습니다.

rexpert 공식필드(javascript) 점검일 주기 계산