Source Code
package MyPackage;
import java.util.Scanner;
public class TakingUserInput {
public static void main(String[] args) {
Scanner scan = new Scanner (System.in);
System.out.println("Enter any data");
int user_input_data = scan.nextInt();
/*
scan.nextInt(); -- Integer
scan.nextDouble(); -- Double
scan.nextline(); -- String
scan.nextfloat(); -- float */
System.out.print("Entered data is ");
System.out.print(user_input_data);
}
}
Output
Enter any data
10
Entered data is 10
0 Comments