일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
Tags
- 한번에끝내는JavaSpring웹개발마스터초격차패키지Online
- java기초
- 데이터베이스
- java
- ncs
- 자바
- 패스트캠퍼스후기
- 디자인
- linux
- 재택근무
- String
- 자바기본
- 스프링
- javabasic
- 리눅스
- Spring
- 패캠챌린지
- js
- 직장인인강
- 자바연습문제
- 한번에끝내는JavaSpring웹개발마스터초격차패키지Online강의
- 웹
- 자바기초
- DB
- 직장인자기계발
- 국비
- 패스트캠퍼스
- 자바예제
- DesignPattern
- 디자인패턴
Archives
- Today
- Total
FIF's 코딩팩토리
자바 기초 NCS교육과정(44)-컬렉션3 본문
반응형
1 배열 구조로 데이터 관리 : Vector, ArrayList
ArrayList -추가-(순차적으로 처리할때 사용)
2 링크로 데이터 관리 : LinkedList
삽입, 삭제-(비순차적으로 처리할때 사용)
3 List을 구현해놓은 컬렉션
Vector,ArrayList,LinkedList은 add()해준 순서대로 데이터 관리를 해준다.
Java190_LinkedList.java
public class Java190_LinkedList { public static void main(String[] args) { ArrayList<String> aList= new ArrayList<String>(); aList.add(new String("java")); aList.add(new String("jsp")); aList.add(new String("spring")); System.out.println(aList); System.out.println("//////////////////////"); LinkedList<String> aNode = new LinkedList<String>(); aNode.add(new String("java")); aNode.add(new String("jsp")); aNode.add(new String("spring")); System.out.println(aNode); //삽입 aNode.add(1, new String("ajax")); System.out.println(aNode); //삭제 aNode.remove(2); System.out.println(aNode); } }

Java191_LinkedList.java
public class Java191_LinkedList { public static void main(String[] args) { LinkedList<String> aNode = new LinkedList<String>(); //추가 aNode.add(new String("java")); aNode.add(new String("jsp")); aNode.add(new String("spring")); System.out.println(aNode); ListIterator<String> ite=aNode.listIterator(); System.out.println("앞->뒤"); while(ite.hasNext()) System.out.println(ite.next()); System.out.println("뒤->앞"); while(ite.hasPrevious()) System.out.println(ite.previous()); } }

stack(스택)
1 LIFO(Last In First Out) : 마지막에 저장된 요소를 먼저 꺼낸다.
2 수식계산, 수식괄호검사, undo/redo, 뒤로/앞으로
Java192_LinkedList.java
public class Java192_LinkedList { public static void main(String[] args) { LinkedList<String> nStack = new LinkedList<String>(); //추가 nStack.push(new String("java")); nStack.push(new String("jsp")); nStack.push(new String("spring")); while (!nStack.isEmpty()) System.out.println(nStack.pop()); } }

Queue(큐)
1. FIFO(First in First Out) : 제일 먼저 저장한 요소를 제일 먼저 꺼내온다.
2. 최근사용문서, 인쇄작업대기목록, 버퍼
Java193_LinkedList.java
public class Java193_LinkedList { public static void main(String[] args) { LinkedList<String> nQueue=new LinkedList<String>(); //추가 nQueue.offer(new String("java")); nQueue.offer(new String("jsp")); nQueue.offer(new String("spring")); // System.out.println(nQueue.get(1)); while(!nQueue.isEmpty()) System.out.println(nQueue.poll()); //index 가능, 메모리에서 아예 지우면서 꺼냄 } }

반응형
'Back-End > 국비 NCS교과과정' 카테고리의 다른 글
자바 기초 NCS교육과정(46)-컬렉션 문제풀이 (1) | 2019.08.02 |
---|---|
자바 기초 NCS교육과정(45)-컬렉션4 (0) | 2019.08.02 |
자바 기초 NCS교육과정(43)-컬렉션2 (0) | 2019.08.02 |
자바 기초 NCS교육과정(42)-컬렉션1 (0) | 2019.08.01 |
자바 기초 NCS교육과정(41)-스트림 문제풀이 (0) | 2019.08.01 |