I've tried couple of things to make this code work, but it didn't.
my goal is to instantiate nums[] with numbers {0, 1, 2, .... n-1}. nums has no size, so I used list that instantiate nums with zeros. Keep in mind that the result must be an array (nums).
int nums[] = {}; int n = 0;
Scanner scanner = new Scanner(System.in);
System.out.println("Enter the number:");
n = scanner.nextInt();
ArrayList<Integer> listNum = new ArrayList<Integer>();
nums = new int[listNum.size()];//instantiate nums with zeros
//nums = listNum.toArray(nums);
for (int i =0; i < n; i++){
nums[i] = i;
}
numsafter you ask the value forn? The size will be known at that point.