In this tutorial, we will learn writing Java program to calculate the square of a given number. Our program will take a number as an input and will return the square of that number as output.
What is Square of Number?
When a number is multiplied to itself once, resultant number is known as square of number.
For example:
Suppose we want to calculate the square of 5.
Square of 5 = 5^2 = 5*5 = 25.
Program to calculate square of number in Java
Output

Explanation
For input 5, the output generated by our program is 5.0*%.0 i.e. equals 25.0.