Added a new point on finally keyword! (#18538)

A new point about finally keyword is demonstrated with the help of an example.
pull/18542/merge
Prem Kagrani 2018-10-14 22:01:28 +05:30 committed by Quincy Larson
parent 0872c911ce
commit 9cd52ab698
1 changed files with 14 additions and 0 deletions

View File

@ -17,3 +17,17 @@ try {
// except when System.exit() is called in "try" or "catch" blocks;
}
```
The finally block does not need the catch block to precede it.There can also be a finally block without the catch block.
***Example:***
```java
try {
//Normal code
System.out.println("hello world!");
} finally {
System.out.println("In finally block");
}
```
The above code works fine even though the catch statement is not used.