Java examples for Language Basics:int
Redirect input to console read
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner keyboard = new Scanner(System.in); int val; System.out.print("Enter an integer please:"); val = keyboard.nextInt(); val *= val; // squared the input value System.out.println("Squared value=" + val); }//from w ww . j a va 2 s .c o m }