Java - Get input from the keyboard using Scanner object


Java - Get input from the keyboard using Scanner object

CODE
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); System.out.print("Enter Data: "); String data = sc.nextLine(); //nextInt() is used to get integer input from the console //sc.nextInt(); sc.close(); } }

Comments