본문 바로가기

JavaCode(review)

(51)
반응형
Comparable / Comparator - Theater 코딩 이용 https://jeong-pro.tistory.com/m/173 개념참고. Theater 코딩서 이미 좌석정렬했는데, 가격순 정렬도 보고싶다? comparable(cmopareTo)를 수정할 순 없고, 가격순 comparator 추가! Comparable : public class xxxx implement Comparable{ ....@override...CompareTo() } 이용 참고)CompareToIgnoreCase() : 대소문자 무시 Comparator : implement 이용 안함. 1. comparator type의 object 생성 -(여러개 comparator 생성가능) 2. 주로 익명 Class이용하여 compare()이용하여 initialization static final C..
Collections.binarySearch(); / Theater코딩에 binarySearch 이용 sorted list(정렬된 리스트)에서 검색 빠르게 처리 하고싶을때, 쓰면 좋다.( 검색결과는 index값으로 전환됨.) comparator를 사용하며, 찾지 못하면 - 값. ex) ascending order일때 int index = Collections.binarchSearch(List, seachKey) ; or int index = Collections.binarchSearch(List, searchKey, 지정한comparator); -1. desceding order 일때 int index = Collections.binarchSearch(List, searchKey, Collections.reverseOrder); -2. List of user-defined class objects 일때 ..
Collection 개념코딩 - theater coding / string.format이용. collection : sava data /(like interface) collection core interface > List, Set, Queue, Deque, / Map 걍 List aa= new ArrayList 랑 비슷 개념.(List가 ArrayList, linkedList, vector등으로 맘대로 정의가능한것처럼.) >collection은 더 포괄적(generic)한 개념 EX) private Collection seats = new Listhashset(); private Collection seats = new LinkedList(); new LinkedHashSet .........collection 하위에 있는것들로 define가능 (단, TreeSet처럼 one level do..
자바 용어 사이트 oracle java tutorial https://docs.oracle.com/javase/tutorial/ The Java™ Tutorials The Java Tutorials have been written for JDK 8. Examples and practices described in this page don't take advantage of improvements introduced in later releases and might use technology no longer available. See JDK Release Notes for information about new fe docs.oracle.com
binary search tree https://yaboong.github.io/data-structures/2018/02/12/binary-search-tree/Binary Search Tree (BST) - Java개요 Binary Search Tree (BST) 개요 삽입, 탐색, 순회, 삭제 구현 - Java 전체 코드 보기yaboong.github.io
Static initialization block POINT] constructor 혹은 other methods보다 우선으로 print out된다. //SIBTest Class// static initialization block 설명위한 package com.timbuchalka; public class SIBTest { public static final String owner; // public static final field static { //static initialization blockV owner = "tim"; System.out.println("SIBTest static initialization block called"); } public SIBTest() { //constructor System.out.println("SIB ..
Final statement / 1.개념 코딩/ 2. password 암호화 코딩 다른 개발자가 실수로라도 값 변경 never / 보통 상수 define시 사용됨 ex) Math.PI =3.xxxxx ( from final class math) 즉, 한번 assigned된 final 값은 변경 불가 예) final field, final method, final class private final int a = 1; public final void add { } public final class Math{ } // SomeClass : final 개념설명 위한 package com.timbuchalka; public class SomeClass { private static int classCounter = 0; //static - memory public final int insta..
Static Statement Variable이 static이냐 아니냐에 따른 다른 결과값. (Static : memory기능 있음.) numInstance값 증가의 다른 결과. 1. non static : 다음 실행때 초기값에서 다시 시작 2. static : 다음실행때 저장된 값에서 시작(이전 실행의 결과값) 1. Non static 변수(numInstances) > 결과값 1, 1, 1 package com.timbuchalka._static; //StaticTest Class public class StaticTest { private int numInstances = 0;//non static variablesV private String name; public StaticTest(String name) { //constru..