Use the pow method to square a number - Java Language Basics

Java examples for Language Basics:Math

Description

Use the pow method to square a number

Demo Code

public class Main {
  public static void main(String[] args) {
    double x = 4.0;
    double y = Math.pow(x, 2);   // a is now 16;

    System.out.println(y);/*from   ww  w  .  ja  v a2s.  co m*/
  }
}

Related Tutorials