기타/What I Learned

[TIL] 자료구조 - 연결리스트 테스트

가죽방패 2022. 3. 29. 10:43

※ 연결리스트 테스트

- 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도 가능
}