+ 1
What is the difference between final and finally key words?
6 Antworten
+ 11
well final and finally both came in Java.
final keyword can be used along with variable, method and Class in Java.
If you make a variable final, you can not change it's value, it will act like a constant. final variables are initialized at the time of creation except in case of blank final variable which is initialized in Constructor.
If you make a method final in Java, you can not overrideit in sub class . If you make a class final means it can not be sub classed. Making a class final automatically makes all its method final and this is sometime required due to security reason, This is one of the reason Why String is final in Java.
and finally is used in exception handling with try and catch block
finally block has special advantage over catch that its guaranteed to be executed despite whether Exception is thrown or not, this makes it, an ideal place to close system resource
+ 11
it's not compulsory in exception handling but it generally used with exception handling
but finally block will execute compulsory in any place it used
refer this code and if you have any query then asked again
0
finally block is really compulsory in exception handling?
0
Mllnono.zzz mm 6%
6966!9.6%?9?36966633533055865?.9⃣ 51686?969666.696393?356