Use static import to bring sqrt() and pow() into view. : Static Import « Class Definition « Java Tutorial






import static java.lang.Math.pow;
import static java.lang.Math.sqrt;

class Hypot {
  public static void main(String args[]) {
    double side1, side2;
    double hypot;

    side1 = 3.0;
    side2 = 4.0;

    hypot = sqrt(pow(side1, 2) + pow(side2, 2));

    System.out.println("Given sides of lengths " + side1 + " and " + side2 + " the hypotenuse is "
        + hypot);
  }
}








5.31.Static Import
5.31.1.Static import
5.31.2.Static importing the Math Class Methods
5.31.3.Use static import to bring sqrt() and pow() into view.