인터페이스가 예외를 throw하는 곳에서는이 코드를 읽지 만 구현하는 클래스는 예외를 던지거나 catch하지 않습니다. 이유는 무엇입니까? 그것은 자바에서 합법적인가 안전합니까?Java 인터페이스가 예외를 throw하지만 인터페이스 구현이 예외를 throw하지 않습니다?
import java.rmi.*;
public interface MyRemote extends Remote {
public String sayHello() throws RemoteException;
}
import java.rmi.*;
import java.rmi.server.*;
public class MyRemoteImpl extends UnicastRemoteObject implements MyRemote{
public String sayHello() {
return "Server says, 'Hey'";
}
public MyRemoteImpl() throws RemoteException {}
public static void main (String[] args) {
try {
MyRemote service = new MyRemoteImpl();
Naming.rebind("RemoteHello", service);
} catch(Exception ex)
{
ex.printStackTrace();
}
}
}
http://www.coderanch.com/t/399874/java/java/Methods-throwing-Exception-Interface –
에서 토론을 확인해 보는 것이 좋습니다. 맞습니다. 그리고 Cheetter가 게시 한 링크를보아야하며 대답으로 게시해야 할 수도 있습니다 .. – Thihara
Thanks Thihara. 그렇게 했어. –