Math

Math.pow

To raise a number to a power, use Math.pow. The operator ^ means XOR in Java.

System.out.println(Math.pow(10, 3)); // 1000.0
System.out.println(10 ^ 3); // 9 -> 1010 XOR 0011 = 1001

You might use x * x instead of Math.pow(x, 2).