trying to make an array, and want the elements to be however large the input will be. eventually this should take x amount of numbers, place in an array, and return the average. But first I need to figure out how placing the size of the elements in the array will be done.
import java.util.Scanner;
import java.util.ArrayList;
//needs to be an array
public class statsv2
{
public static void main (String args[])
{
int[] a= new int[5];
Scanner sc=new Scanner(System.in);
System.out.println("Please enter numbers...");
for(int j=0;j<5;j++)
{
a[j]=sc.nextInt();
}
}
}
So I essentially want the that '5'(which appears twice) to be however many times the user keeps entering new numbers