목록Language/Java2 (11)
정보보안공부
*** j2.object.sysyem - Employee -> Employee클래스 정의 -> 생성자 public int eno; 선언후 public Employee(int eno) { this.eno = eno; } -> public void finalize(){ System.out.println("Employee(" + eno + ") 이 메모리에서 제거됨."); } System.gc()선언시 finalize()메소드 실행 *** j2.api.System - GcExample -> Employee emp; -> emp = new Employee(1); -> emp = null; -> emp = new Employee(2); -> emp = new Employee(3); -> 생성자에의해 Employe..
*** NumMatch -> input = new Scanner(System.in).nextInt(); nextInt() 입력 데이터를 정수형으로처리, 영어 알파벳입력하는 경우 Exception발생 -> if(input 100) { System.out.print("1부터100사이 정수입력하시오:"); } Exception으로도 표현가능 -> 두가지의 Exception실행 가능 *** NumMatchError1 : 첫번째 Exception실행 -> 첫번째 Exception발생 정수형대신 알파벳 입력하는 경우 예외처리 -> try { input = new Scanner(System.in).nextInt(); 부터 if(input 100 ) { } 까지 try..
*** NullPointerExample -> data = null 일때 System.out.println(data.toString()); 은 오류 발생 -> Exception발생할 수 있는 부분을 블럭처리한다. try { data = null; System.out.println(data.toString()) } catch로 Exception 처리 catch(Exception e) { System.out.println("예외처리 합니다.") } *** ExceptionTest -> (int)(Math.random() * 10) 이 0이나올경우 exception발생 -> Exception발생할 수 있는 부분을 블럭처리한다. try { result = number / (int)(Math.random() * ..