
how to get values using datainputstream in java?

Hi Friend,
Try the following code:
import java.io.*;
class ReadFromDataInputStream{
public static void main(String[] args) throws Exception{
int arr[]=new int[10];
DataInputStream in = new DataInputStream(System.in);
System.out.println("Enter Name: ");
String name=in.readLine();
System.out.println("Enter Age: ");
int age=in.readInt();
System.out.println("Name is: "+name);
System.out.println("Age is: "+age);
}
}
Thanks
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.