How do you want to read the input from the user? Is it from the command line? From a file or what? If it's a command line input, I'd suggest you to just use Scanner class... It's the same thing, but it's make your code looks nicer lol...
and then use this method:
Quote:
String nextLine()
Advances this scanner past the current line and returns the input that was skipped.
|
Code:
import java.util.Scanner;
public class Test {
public static void main(String[] args) {
Scanner s = new Scanner();
int[] num = new int[10];
int cnt = 0;
while (cnt < num.length) {
System.out.print("Enter number: ");
String number = s.nextLine();
int[cnt] = Integer.parseInt(number); // you need to add try.. catch.. block
System.out.println(int[cnt]);
}
}
} let me know if it works lol.. I didn't test it
