/** * @author lautturi.com * Java example: get input from user using scanner in java */ import java.util.*; public class Lautturi { public static void main(String[] args) { // get input from standard input stream Scanner scan = new Scanner(System.in); System.out.println("Type something:"); String next = scan.next();// scanner will take the input System.out.println(next); //String line = scan.nextLine();// scanner will take the whole line //System.out.println(line); } }
output:
Type something: hello lautturi hello