문제

I'm writing a program in Java, and nearly every method in one of my classes is written like:

public void doStuff() throws AWTException{}

Is there a way for me to get rid of the extra step of typing throws AWTException for each method, and somehow do it for the entire class?

도움이 되었습니까?

해결책

Sorry, No. There is no way to do this in Java.

다른 팁

if you throw exception with class level then how you identify that on which type of exception is thrown by method... or on which method it throw exception.

so it is not allow in java...and also its not a good coding with java

You can by throw exception at constructor level. You can see how FileInputStream force us to throw IO exception while creating object of it.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top