Our Best Offer Ever!! Summer Special - Get 3 Courses at 24,999/- Only. Read more
Hire Talent (HR):+91-9791 444 054

General

Final keyword in Java

Final keyword in Java

Final keyword in Java

Final keyword in java – It’s different way to use constants. This keyword can be use with below.

  • Variable
  • Method
  • Class

Final variable is must to be initialized else it will throw compile time error and can be initialize only one time. There are servel ways are there to initialize final variable. One way direct value can be assign , if not assign then can initialize in constructor. If variable defined as static then it can initialized inside static block.

Example:

final int QUEUE_SIZE_VALUE=2320;  // variable
  final void finalTest(){   // method
      System.out.println("FinalTest Method");
   }   
final class finalTestExample{  // Class
}

Click Here-> Get Java Training with Real-time Projects

Besant Technologies WhatsApp