Java program to print square series using Math.pow() method. The following Java program prints the square series 0, 1, 4 , 9, 16, 25, etc.

import java.io.*;
public class SquareSeries
{
	public static void main(String args[]) throws IOException
	{
		int n;
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		System.out.println("Enter no.of elements in series: ");
		n = Integer.parseInt(br.readLine());

		if(n>0)
		{
			System.out.println("Series:");
			for(int i=0; i<n; i++)
			{
				System.out.println((int)(Math.pow(i,2)));
			}
		}

		else
			System.out.println("You Entered the Wrong no.");

	}
}

Output for Square Series

Enter no.of elements in series: 
5
Series:
0
1
4
9
16