목록개발/JAVA (11)
개발용
* Collection :: 사용자 정의 Object 정렬 : Collections.sort([Collection], new Comparator() { @Override public int compare(Map obj1, Map obj2) { return (obj1.get([KEY_NAME])).compareTo(obj2.get([KEY_NAME])); }}); : 두번째 파라미터로 비교 객체를 사용, compare메소드 override
더블클릭 : break point ctrl+shift+b : break point f11 : debugging F5 : step into - 메소드 안으로 들어감 F6 : step over - 메소드 자체를 실행시킴 F7 : step return - 실행하던 것을 끝내고 호출한 곳으로 돌아감 F8 : resume ctrl+r : 커서가 있는 곳까지 실행 ctrl+f2 : terminate
Stream : 데이터의 흐름, 데이터의 흐름을 형성해 주는 통로 Stream 최상위 클래스 : InputStream / OutputStream *InputStream : -public abstract int read() throws IOException : 1byte씩 읽어옴 / return -> 읽어온 1byte의 내용(int형) -public int read(byte[] b) throws IOException : return -> size of data(bit) -public void close() throws IOException *OutputStream : -public abstract void write(int b) throws IOException : 1byte씩 씀 -public void ..
1. 제네릭 : 을 이용하여 데이터 형에 관계없이 지역변수, 메소드를 사용할 수 있게 함 ex) class Class_name { private T var_name; public T met_name(D tmp){ //... } } cf. 상속관계인 객체들을 다룰 때 다형성을 이용하여 최상위 클래스 객체를 T로 설정하면 용이하다. 2. 프레임워크 : 잘 정의된 약속된 구조나 골격 3. 컬렉션 : 데이터의 저장, 그리고 이와 관련있는 알고리즘을 구조화 해 놓은 프레임워크 (컬렉션은 데이터의 저장, 그리고 이와 관련있는 알고리즘을 구조화 해 놓은 프레임워크, 쉽게는 자료구조와 알고리즘을 클래스로 구현해 놓은 것) -Collection -> Set -> List -> Queue -Map -------------..
* 메소드 영역(method area) : 메소드의 바이트코드, static 변수 * 스택 영역(stack area) : 지역변수, 매개변수 * 힙 영역(heap area) : 인스턴스
ex) class Exc_name extends Exception { Exc_name() { super("Error-Message"); } } "Exception던진 메소드를 호출하는 상위 메소드에서 예외처리 해줘야 함 : try-catch || throws" *Solution -try-catch : 필요한 곳에서 던지고 받음 try { ... if(EXCEPTION_OPTION) { throw new Exc_name(); } } catch(Exc_name e) { System.out.println(e.getMassage()); //Error-Message 출력 System.out.println(e.stackTrace()); } -Method_name() throws Exc_name(throw Exc_n..
abstract(추상) : 객체를 생성할 수 없음 *Class : abstract class class_name{...} -클래스 내에 추상 메소드가 하나만 있어도 추상 클래스. -객체를 생성하지 않을 거면 추상클래슬 만들어서 상속시킴. *Method : public abstract void met_name(){...} -body가 없는 메소드. -상속받은 클래스에서 구현해야 함. Interface : 순수하게 모든 멤버 메소드가 abstract -All 메소드 : (자동으로) public abstract -All 변수 : (자동으로) public static final => 상수만들어서 사용할 때 좋음 -다중상속구현 가능 -인터페이스 간 상속 가능 *interface를 implements한 클래스 -모..
class안의 class 1. nested class (static) : 외부 클래스 만들지 않고 사용 가능, non-static 멤버를 참조할 수 없다 ex) class OuterClass { private string name = "NAME"; static class NestedClass { public void fun_name() { // name(non-static)을 참조할 수 없음 } } } public static void main() { NestedClass nsc = new OuterClass.NestedClass(); nsc.fun_name(); } 2. inner class : 반드시 외부 클래스부터 만들어야함 ex) class OuterClass { class InnerClass {..