Variable Dynamic Initialization : Variables « Language « Java Tutorial






public class MainClass {
  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);
  }
}
Hypotenuse is 5.0








1.9.Variables
1.9.1.Variables
1.9.2.Variable Dynamic Initialization
1.9.3.Demonstrate lifetime of a variable
1.9.4.shows the proper way to declare a class variable named helloMessage
1.9.5.You don't have to place class variable declarations at the beginning of a class.
1.9.6.helloMessage variable is declared as a local variable: