Java examples for Language Basics:Math
Use the pow method to square a number
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*/ } }