Programming/Java83 TIL : 자바 컴파일 학습 목표 자바 컴파일 main 메서드 자바의 주석 자바의 컴파일 과정 .java 확장자 파일의 소스 코드 작성 javac 명령어로 컴파일 컴파일러가 읽어서 오류가 없나 확인하고 통과되면 확장자가 .class인 파일을 만든다. java 명령어로 실행 java 명령어로 클래스 파일을 실행할 때 확장자를 적지 않는 이유는 알아서 .class 파일들을 찾아서 동일한 이름의 클래스를 찾아서 실행하 때문이다. main 메서드 main 메서드가 없는 클래스 파일을 실행하면 위와 같은 에러가 발생한다. 실행을 목적으로 하는 모든 자바 클래스는 main() 메서드가 반드시 있어야 한다. 자바 프로그램의 진입점은 main() 메서드기 때문에 반드시 있어야 한다. *[접근 제어자; access modifier] [리턴 타.. 2023. 6. 2. [Java] - TreeSet 살펴보기 TreeSet TreeSet은 이진 검색 트리라는 자료구조의 형태로 저장하는 컬렉션 클래스이다. 이진 검색 트리 장점 정렬, 검색, 범위 검색에 높은 성능을 보이는 자료 구조이다. 특히 검색효율이 뛰어난 자료구조이다. 그 이유를 정리해보자. 이진 트리는 여러 개의 노드가 서로 연결된 구조이며, 각 노드에는 최대 2개 노드를 연결할 수 있다. 이진 트리는 노드에 자식 노드를 계속해서 확장해 나갈 수 있다. 부모 노드와 자식 노드 2개를 코드로 표현해 보면 아래와 같다. class TreeNode{ TreeNode left; Object element; TreeNode right; } 이진 트리의 특징은 부모 노드 왼쪽에는 부모 노드의 값보다 작은 값을 ( 왼쪽 노드 < 부모 노드 ) 오른쪽에는 부모 노드의.. 2021. 3. 11. [Java] - 정렬하기 --> comparable, comparator (복습해서 정리하기) Comparator와 Comparable 모두 인터페이스로 컬렉션을 정렬하는데 필요한 메서드를 정의하고 있다. 차이점 Comparable - 기본 정렬기준을 구현하는 데 사용 Comparator - 기본 정렬기준 외에 다른 기준으로 정렬하고자할 때 사용 jeong-pro.tistory.com/17 2021. 3. 7. [Java] - Iterator 살펴보기 Iterator - api 문서 살펴보기 public interface Iterator An iterator over a collection. Iterator takes the place of Enumeration in the Java Collections Framework. Iterators differ from enumerations in two ways: Iterators allow the caller to remove elements from the underlying collection during the iteration with well-defined semantics. Method names have been improved. Iterator는 자바 컬렉션에 저장된 요소에 순차적으로 접근하.. 2021. 3. 6. [Java] - Deque 기본 사용법 Deque(double ended queue) public interface Deque extends Queue A linear collection that supports element insertion and removal at both ends. The name deque is short for "double ended queue" and is usually pronounced "deck". Most Deque implementations place no fixed limits on the number of elements they may contain, but this interface supports capacity-restricted deques as well as those with no f.. 2021. 3. 6. [Java] - priorityQueue 사용법 priorityQueue priorityQueue는 Queue 인터페이스를 구현한 클래스다. java api 문서를 살펴보자. 저장한 순서에 관계없이 우선순위가 높은 요서부터 꺼내게 된다는 특징이 있다. An unbounded priority queue based on a priority heap. PriorityQueue는 저장공간으로 배열을 사용하며, 각 요소를 힙(heap)이라는 자료구조의 형태로 저장한다. The elements of the priority queue are ordered according to their natural ordering, or by a Comparator provided at queue construction time, depending on which constr.. 2021. 3. 6. 이전 1 2 3 4 5 6 7 ··· 14 다음