
how to getting values and storing values in array by using datainputstream?

Hi Friend,
Try the following code:
import java.io.*;
import java.util.*;
class ReadFromDataInputStream{
public static void main(String[] args) throws Exception{
int arr[]=new int[10];
DataInputStream in = new DataInputStream(System.in);
BufferedReader br = new BufferedReader(new InputStreamReader(in));
System.out.println("Enter Numbers: ");
for(int i=0;i<arr.length;i++){
arr[i]=Integer.parseInt(br.readLine());
}
System.out.println("Array Elements are: ");
for(int i=0;i<arr.length;i++){
System.out.println(arr[i]);
}
}
}
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.