[char array->String]

char cArr[] ;  

String s = String.valueOf(cArr);

 

 

 

 

1. Array에 특정한 Object가 있는지 Check:


Arrays.asList(yourArray).contains(yourValue)

Warning: this doesn't work for arrays of primitives (see the comments).


2. LinkedList 에서 삭제 및 data Set.

Size()가 변하는 loop안이라면 Iterator를 사용하여 삭제하는 게 안전.

아니면 뒤에서부터 앞으로 Loop돌면서 삭제. (테스트 필요)

 

Iterator<String> iter = list.iterator();
while (iter.hasNext()) {  
     String s = iter.next(); //꼭 next먼저 호출.
     if (s.equals("a"))  iter.remove();  //원래 remove는 가장최근 return()한 걸 삭제하는 이상한 함수임.
}


ListIterator의 경우에는 iter.set() 함수도 매우 쓸만하다. //이 역시, 가장 장최근 return()한 걸 치환.


3. LinkedList  에 특정위치에 data 넣고 싶을때?

    LikedList<String> list = new LinkedList<String>();

    list.add("a");list.add("c");


    <a,c사이에 b를 넣고 싶으면>

    list.add(1,"b");   // index를 이미 안다면,  방법을 쓰거나..

    list.add ( getIndex("a")+1, "b"); //모른다면.. 이방법. 근데이게 getIndex가 속도가 의심이 됨..  

     최상의 방법은? 뭘까요?  
     자가 List라면  node.next.next = node.next;  node.next = new Node(); 하면 되는데.. 
     

     이런방법 없을까요?


     

      

     

      

    

    


Posted by yongary
,