CAN WE INTIALIZE BLANK FINAL VARIABLE IN JAVA?

Royce Roy

Total Post:51

Points:255
Posted by  Royce Roy
Java 
 576  View(s)
Ratings:
Rate this:
  1. Mayank Tripathi

    Post:807

    Points:4035
    Can we intialize blank final variable in java?

    Yes, but only in constructor. For example:


    1. class Bike10{  
    1.   final int speedlimit;//blank final variable  
    1.     
    1.   Bike10(){  
    1.   speedlimit=70;  
    1.   System.out.println(speedlimit);  
    1.   }  
    1.   
    1.   public static void main(String args[]){  
    1.     new Bike10();  
    1.  }  

    1. Output:70

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!