안드로이드 개발 질문/답변
(글 수 45,052)
ArrayList<String> old_qlist;
ArrayList<String> new_qlist;
이 두가지의 arraylist가 있다면
old_qlist에 new_qlist의 내용을 복사 하려면 어떻게 해야하나요..?
copyArray(old_qlist, new_qlist);
이렇게 해도 복사가 안됩니다...ㅠㅠ
ArrayList<String> new_qlist;
이 두가지의 arraylist가 있다면
old_qlist에 new_qlist의 내용을 복사 하려면 어떻게 해야하나요..?
copyArray(old_qlist, new_qlist);
이렇게 해도 복사가 안됩니다...ㅠㅠ

안드로이드를 매우 사랑하는!
2010.09.17 20:52:55
아...copyArray()는 제가 만든건데요..
private ArrayList<String> copyArray( ArrayList<String> old_qlist , ArrayList<String> new_qlist)
{
for(int i = 0; i < new_qlist.size(); i++)
{
old_qlist.add(new_qlist.get(i));
}
return old_qlist;
}
이럲게 만들었습니다..
private ArrayList<String> copyArray( ArrayList<String> old_qlist , ArrayList<String> new_qlist)
{
for(int i = 0; i < new_qlist.size(); i++)
{
old_qlist.add(new_qlist.get(i));
}
return old_qlist;
}
이럲게 만들었습니다..
2010.09.17 22:23:43
자세한 자바 문법은 생략이구요(사실 잘 모름...^^)...아래와 같은 형태로 하면 일단 됩니다.
OldArrayList<String> old_qlist = new OldArrayList();
ArrayList<String> new_qlist;
new_qlist = old_qlist.clone();
class OldArrayList extends ArrayList implements Cloneable{
public OldArrayList() {
super();
}
public Object clone(){
Object o = null;
try{
o = super.clone();
}catch (Exception e){System.out.println("can't clone object");}
return o;
}
}



