package nilpointer.net;
import java.util.Scanner;
public class Demo {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.println("Input:");
System.out.print("id: ");
int id = scanner.nextInt();
scanner.nextLine(); // clear input buffer
System.out.print("name: ");
String name = scanner.nextLine();
System.out.print("price: ");
double price = scanner.nextDouble();
System.out.print("status: ");
boolean status = scanner.nextBoolean();
System.out.println("Output:");
System.out.println("id: " + id);
System.out.println("name: " + name);
System.out.println("price: " + price);
System.out.println("status: " + status);
}
}
Input:
id: 123
name: Name 1
price: 5.6
status: true
Output:
id: 123
name: Name 1
price: 5.6
status: true