You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+35-28
Original file line number
Diff line number
Diff line change
@@ -2296,21 +2296,25 @@ Some of the common main thread exception are as follows:
2296
2296
2297
2297
**Throw** keyword is used in the method body to throw an exception, while **throws** is used in method signature to declare the exceptions that can occur in the statements present in the method.
2298
2298
2299
-
**Throw Example:**
2299
+
**Example:**
2300
2300
2301
2301
```java
2302
-
publicclassThrowExample {
2303
-
voidcheckAge(intage) {
2304
-
if(age <18)
2305
-
thrownewArithmeticException("Not Eligible for voting");
2306
-
else
2307
-
System.out.println("Eligible for voting");
2308
-
}
2309
-
publicstaticvoidmain(Stringargs[]) {
2310
-
ThrowExample obj =newThrowExample();
2311
-
obj.checkAge(13);
2312
-
System.out.println("End Of Program");
2313
-
}
2302
+
/**
2303
+
* Throw in Java
2304
+
*/
2305
+
publicclassThrowExample {
2306
+
voidcheckAge(intage) {
2307
+
if (age <18)
2308
+
thrownewArithmeticException("Not Eligible for voting");
2309
+
else
2310
+
System.out.println("Eligible for voting");
2311
+
}
2312
+
2313
+
publicstaticvoidmain(Stringargs[]) {
2314
+
ThrowExample obj =newThrowExample();
2315
+
obj.checkAge(13);
2316
+
System.out.println("End Of Program");
2317
+
}
2314
2318
}
2315
2319
```
2316
2320
@@ -2323,23 +2327,26 @@ at Example1.checkAge(Example1.java:4)
0 commit comments