Dynamic Initialization

Java allows variables to be initialized dynamically.


public class Main {
  public static void main(String args[]) {

    // c is dynamically initialized
    double c = Math.sqrt(2 * 2);

    System.out.println("c is " + c);
  }
}

The output from the code above is


c is 2.0

Home 
  Java Book 
    Language Basics  

Variables:
  1. Variable stores value in a Java program
  2. Assignment Operator
  3. Dynamic Initialization
  4. Scope and Lifetime of Variables