IT
[java]어레이에서 ArrayList를 만듭니다
어레이에서 ArrayList를 만듭니다 질문 나는 배열이 초기화 된 것처럼 보입니다.Element[] array = {new Element(1), new Element(2), new Element(3)}; 이 배열을 ArrayList 클래스의 객체로 변환하고 싶습니다.ArrayList arraylist = ???; 답변 new ArrayList(Arrays.asList(array)); 답변주어진:Element[] array = new Element[] { new Element(1), new Element(2), new Element(3) }; 가장 간단한 대답은 다음과 같이해야합니다.List list = Arrays.asList(array); 이것은 잘 작동합니다.그러나 어떤주의 사항 : The list..
2022. 3. 31. 13:21
최근댓글