CodesJava

Easy learning with example program codes

what is 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

/**
 * This class is used to show the example of blank final variable.
 * @author codesjava
 */
class Test{
	//blank final variable which can only be 
        //initialize through constructor.
	final int num;
 
	Test(int n){
		num = n;
		System.out.println("Num = " + num);
	}
}
public class FinalExample5 {
	public static void main(String args[]){
		new Test(100);
	}
}

Output

Num = 100

Java interview questions on final keyword

Sign Up/ Sign In
Ask a Question


Industrial Training

We offers Placement Oriented Training on Java, Spring, JSF, Hibernate, PHP, AngularJS, Angular 4, PLSQL, Oracle BI Publisher etc. We also provides Online training, please mail us at hr@codesjava.com.

Development

We also provides the Development services for Website Development , Java Development, PHP Development, Android App Development etc. You can contact us on hr@codesjava.com.

Copyright © 2018 CodesJava DMCA.com Protection Status SiteMap Reference: Java Wiki