We Offer 100% Job Guarantee Courses (Any Degree / Diploma Candidates / Year GAP / Non-IT / Any Passed Outs). Placement Records
Hire Talent (HR):+91-9707 240 250

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