I am trying to get input from user using DataInputStream
. But this displays some junk integer value instead of the given value.
Here is the code:
import java.io.*;
public class Sequence {
public static void main(String[] args) throws IOException {
DataInputStream dis = new DataInputStream(System.in);
String str="Enter your Age :";
System.out.print(str);
int i=dis.readInt();
System.out.println((int)i);
}
}
And the output is
Enter your Age :12
825363722
Why am I getting this junk value and how to correct the error?