Here is A Java Program to Demonstrate dynamic initialization by Calculating Hypotenuse of Triangle
Output of Above Java Program
Hypotenuse is 5.0
class DynInit {
public static void main(String args[]) {
double a = 3.0, b = 4.0;
// c is dynamically initialized
double c = Math.sqrt(a * a + b * b);
System.out.println("Hypotenuse is " + c);
}
}
Output of Above Java Program
Hypotenuse is 5.0