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

java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.