by Dinesh Thakur

It is in two types. Those are,


1. Command line arguments

2. By using readLine() method


Through Command line arguments : (used rarely) Arguments can be passed to a java prg at the time of running it. Such arguments are known as command line arguments. Those arguments are stored in the string array which is a parameter of main().



By using readLine() method:


Integer : It is a class belongs to java.lang package.

parseInt(): It is a method. It is supported by the class Integer. It is used to convert a number from string format to integer format.




The method readLine() is used to take input from user at runtime. This method is defined in the class DataInputStream. This class is available in package. By default this method reads any kind of input in String format. That should be converted to the required types. readLine() methods throws an IOException should be handled or throwsclass has to be used. :


It is a package. It contains various classes required for input and output








It is an Exception class. It is a part of packages. It is required to be caught in every method when readLine() is used. Else throws class is used to mention IOException.


It is parameter of the constructor(new) of DataInputStream. It indicates standard input.i.e. Key board. ‘in’ is an object of DataInputStream class. It is required in order to call readLine() method.