I’m a beginner… please bear with me 🙂
This is a code that supposedly reads 10 integers in an array. The InputStreamReader reads in char (that what java Docs said) how to convert the char into int to be saved in the array?
int[] array = new int[10];
System.out.println("Please enter 10 integers. ");
for(int x=1; x <11; x++){
InputStreamReader keyboard = new InputStreamReader(System.in);
// Change char into int
array[x] = keyboard;
}
Thanks
Try this –
Scanner#nextIntscans the next token of the input as anint. And throws