Taking Input from the user in Java
Taking Input From User Three ways to accept the value dynamically From Cmd prompt From keyboard From properties file Cmd prompt: Using main method passing the input values as array of String object (String args[]) Convert the received String objects using wrapper classes as follows: public static xxx parsexxx(String). Ex: To convert String to integer int a = Integer.parseInt(args[0]); From Keyboard: Use Scanner class from java.util.scanner package Scanner s = new Scanner (System.in); int firstNumber = s.nextInt(); From properties file: Create file name db.properties and data as key=value format as follows: Read the properties file using FileReader and properties class in main method as follows: