✔ JAVA CHAPTERS:-
1. Introduction to Java
2. Features of Java
3. Java Virtual Machine
4. D/F B/W JVM, JRE, JDK
5. Java Data Types
6. Java Programs
7. Setting Java Path
8. OOPs Concepts
9. Object & Class In Java
10. OOPs Continued
11. Encapsulation & Polymorphism
12. Method Overloading
13. Method Overriding
14. Dynamic Method Dispatch
15. Association In Java
16. Inheritance in Java
17. Aggregation in java
18. Command Line Argument
19. Execute Command Line
20. Read Input From Command Line
21. Abstract Class In Java
22. Interface in Java
23. Cutom Marker Interface
24. Constructor In Java
25. Package in Java
26. Acess Modifier In Java
27. Static Import In Java
28. Package Class In Java
29. This Keyword
30. Instance Intializer Block
31. Super Keyword
32. Static Keyword
33. Final Keyword
1. Introduction to Java
2. Features of Java
3. Java Virtual Machine
4. D/F B/W JVM, JRE, JDK
5. Java Data Types
6. Java Programs
7. Setting Java Path
8. OOPs Concepts
9. Object & Class In Java
10. OOPs Continued
11. Encapsulation & Polymorphism
12. Method Overloading
13. Method Overriding
14. Dynamic Method Dispatch
15. Association In Java
16. Inheritance in Java
17. Aggregation in java
18. Command Line Argument
19. Execute Command Line
20. Read Input From Command Line
21. Abstract Class In Java
22. Interface in Java
23. Cutom Marker Interface
24. Constructor In Java
25. Package in Java
26. Acess Modifier In Java
27. Static Import In Java
28. Package Class In Java
29. This Keyword
30. Instance Intializer Block
31. Super Keyword
32. Static Keyword
33. Final Keyword
Static Keyword in Java: Previous Learn Servlet
Final Keyword In Java
final is a keyword in java which can be used with instance variables, local variables , methods and classes.
Use of final keyword in java:
1. final variable in java:
A variable declared with final keyword is known as final variable. It may be member variable or local variable. final variables are constants in java and they are generally declared with static keyword. As final variables are treated as constants they can’t reassign. They are initialised at the time of declaration.
Example:
FinalExample1.java
Output:
Note: Inside Anonymous classes only final variables are accessible.
2. final method in java:
A method declared with final keyword is known as final method.
Example:
FinalExample2.java
Output:
Note: A final method can be inherited but can’t be override.
3. final class in java:
A class declared with final keyword is known as final class. A final class can’t be inherited.
Example:
FinalExample3.java
Output:
Note: final method can be inherited.
Example:
FinalExample4.java
Output:
Note: Abstract class and constructor can’t be final.
4. Blank final variable in java:
A variable declared with final keyword but not initialised at declaration time is known as blank final variable. They are initialised at the time of object creation in constructor and can’t change after that.
Example:
FinalExample5.java
Output:
5. static blank final variable in java:
A static variable declared with final keyword but not initialised at declaration time is known as static blank final variable. It can be initialised in a static block only.
Example:
FinalExample6.java
Output:
6. final parameter in java:
A method parameter declared with final keyword is known as final parameter. Its value can’t be changed.
Example:
FinalExample7.java
Output:
Advantages/Benefits of final keyword:
- 1. Performance: JVM kept in cache if variables, methods and classes are declared final.
- 2. Immutable classes: With the help of final keyword we can made immutable classes.