Constant in Java
Constant in Java A constant in java is used to map and exact and unchanging value to a variable name. Final variables are often declared with static keyword in java and treated as constant . Final keyword in variable declaration: Syntax: final datatype v 1 = val 1 , v 2 =val 2, ----------------------V n = Val n ; Ex: public static final double PI = 3.14159; Final keyword in method level: A java method with final keyword is called final method and it cannot be overridden in sub-class . Syntax: final returntype methodname(list of formal parameters) { block of statements; } ...
Comments
Post a Comment