※ 연결리스트 테스트
- Listl 인터페이스를 구현한 LinkedList를 테스트하는 방법은 다음과 같다
public class Tester{
public static void main (String[] args){
static Listl<Integer> List = new LinkedList <Integer>();
int n = 10;
// 연결 리스트 생성
for(int i = 0; i < n; i++)
list.addFirst(i); // addLast도 가능
// 연결 리스트 제거
for(int i = n-1; i>=0; i--)
int x = list.removeFirst(); // removeLast도 가능
}
'기타 > What I Learned' 카테고리의 다른 글
[TIL] 자료구조 - 이중 연결 리스트 (0) | 2022.03.31 |
---|---|
[TIL] 자료구조 - 반복자 (0) | 2022.03.30 |
[TIL] 자료구조 - peek 메소드 (0) | 2022.03.28 |
[TIL] 자료구조 - remove, find (0) | 2022.03.25 |
[TIL] 자료구조 - removeLast 메소드 (0) | 2022.03.22 |