I'm used to python, so this is a bit confusing to me. I'm trying to take in input, line-by-line, until a user inputs a certain number. The numbers will be stored in an array to apply some statistical maths to them. Currently, I have a main class, the stats classes, and an "reading" class.
Two Questions:
I can't seem to get the input loop to work out, what's the best practice for doing so.
What is the object-type going to be for the reading method? A double[], or an ArrayList?
How do I declare method-type to be an arraylist?
How do I prevent the array from having more than 1000 values stored within it?
Let me show what I have so far:
public static java.util.ArrayList readRange(double end_signal){
//read in the range and stop at end_signal
ArrayList input = new ArrayList();
Scanner kbd = new Scanner( System.in );
int count = 0;
do{
input.add(kbd.nextDouble());
System.out.println(input); //debugging
++count;
} while(input(--count) != end_signal);
return input;
}
Any help would be appreciated, pardon my newbieness...