Java: How to square a numberThere are two main ways to square a number in Java: multiplying it by itself and using the Math.pow() function.