Using Static Imports to Import Multiple Static Members of a Type - Java Language Basics

Java examples for Language Basics:import

Description

Using Static Imports to Import Multiple Static Members of a Type

Demo Code

import static java.lang.Math.PI;
import static java.lang.Math.sqrt;
import static java.lang.System.out;

public class Main {  
  public static void main(String[] args) {
    double radius = 21.9;
    double area = PI * radius * radius;

    out.println("Value of PI is: " + PI);    
    out.println("Radius of circle: " + radius);    
    out.println("Area of circle: " + area);
    out.println("Square root of 2.0: " + sqrt(2.0));
  }/*from   w ww . j  a  va  2  s  .  co  m*/
}

Result


Related Tutorials