User input example counts from 0 to number in Java.

Receive a number from user and counts from 0 to number in Java. 

import java.util.Scanner;
public class CounterFor {
	public static void main (String arg[]){
		Scanner xScanner=new Scanner(System.in);
		int number;
		System.out.print("Please enter a number: ");
		number=xScanner.nextInt();
		for(int i=0;i<number+1;i++)
		{
			System.out.print(i+" ");
		}
		xScanner.close();
	}

}