Java development for beginners 4. Input and output from console using Scanner.

We are going to work with input and output from console so that the next video tutorials are more educational and entertaining.

For data input we are going to use the class "Scanner", which has a method next(). This method gives us the next input from the console, which will be kept in the "input" variable.

For the data output, we will continue to use the instruction "System.out.println(x)", as we´ve done in the past video tutorials.

In the class "Tutorial4", we have the code used in the program of the video tutorial:

package tutorial4.edu4java.com;

import java.util.Scanner;

public class Tutorial4 {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		System.out.println("scanner:");
		String input = scanner.next();
		System.out.println("Print input");
		System.out.println(input);
	}
}
<< Previous Next >>