Skip to main content

  | मौसम…

411 समाचार
Public archive edition · Attributed source reporting with original dates · AI drafts are excluded

411 REFERENCE · Wikibooks

Java Programming/Keywords/throws

Reference material by Wikibooks contributors. This retains its source identity and is not 411 news reporting.

is a Java keyword. It is used in a method definition to declare the Exceptions to be thrown by the method. Syntax: public myMethod() MyException1, MyException2 {MyException1 ... } Example: class MyDefinedException extends Exception { public MyDefinedException(String str) { super(str); } } public class MyClass { public static void showMyName(String str) throws MyDefinedException { if(str.equals("What is your Name?")) throw new MyDefinedException("My name is Blah Blah"); } public static void main(String a[]) { try { showMyName("What is your Name?"); } catch(MyDefinedException mde) { mde.printStackTrace(); } } } deep