16. I/O

Input

Dobbiamo prima costruire uno scanner, che deve essere collegato allo standard input System.in, e poi usare i metodi della classe Scanner.

Output

Usare System.out.print oppure System.out.println.

Esempio

public static void main(String args[]) {
	Scanner in = new Scanner(System.in);
	System.out.println("What is your name?");
	String name = in.nextLine();
	System.out.println("How old are you?");
	int eta = in.nextInt();
	System.out.println("Hello " + name + " in one year you will have " + (eta+1)+ " years");
}