전체 글
-
try, catch, finally개발노하우/Java 2007. 6. 4. 12:11
class object{ static int a,b; public static void main(String arg[]){ try{ int a = Integer.parseInt(arg[0]); int b = Integer.parseInt(arg[1]); System.out.println("매게변수로 받은 두 개의 값"); System.out.println("a="+a+"b="+b); System.out.println("====================="); System.out.println("a()메소드 호출 전"); a(); System.out.println("a()메소드 호출 후"); } catch(ArithmeticException e){ System.out.println("Arithmetic..
-
Exception 예외처리개발노하우 2007. 6. 4. 11:46
예외를 처리하는 방법 두가지 - 예외가 발생된 메소드 내에서 처리하는 방법(try, catch절 사용) - 예외가 발생된 메소드를 호출한 메소드에게 예외의 처리를 넘겨주는 방법(throws절 사용) import java.io.*; class object{ public static void main(String arg[]){ try{ FileReader file = new FileReader("a.txt"); int i; while((i=file.read())!=-1){ System.out.print((char)i); } file.close(); } catch(Exception e){ System.out.print("예외 처리 루틴 :"+e+"예외발생"); } } } import java.io.*; cla..
-
자바의 Thread개발노하우 2007. 6. 1. 09:21
class ThreadA extends Thread { // Thread 클래스로부터 상속 ................... public void run(){ // run()필수 // 상위 클래스인 Thread 클래스의 run()메소드를 오버라이딩 하여 // 스레드가 수행하여야 하는 문장들을 기술 // ThreadA ta = new ThreadA(); // ta.start(); // 스레드 객체를 생성하여 스레드를 시작시킨다. } } Runnable 인터페이스에는 run()메소드만 정의되어 있다. public interface Runnable { public void run(){}; // Runnable 인터페이스에 정의된 run()메소드를 오버라이딩 } Runnable 인터페이스를 이용하여 스레드를 ..
-
-
-