I need to create 3 instances of my temperature class. I can do this by typing it three times, but I am sure that it is not a good way to do it. Hence, I searched online and found ArrayList.
I don't understand how to use ArrayList so it can create instances of class in a loop, and I want to access it outside my loop.
For example right now I have
Temperature t1 = new Temperature ();
t1.setDegrees(input.nextDouble());
How do i loop the whole thing above so i dont have to type it three times. I searched online for examples but all i can find is values that are already stored in an ArrayList, instead of new instances being created and being stored inside of the ArrayList. So basically this is what i want to do
Temperature t1 = new Temperature ()
for ( 3 loops )
{
t1.setDegrees(user input) ;
ArrayList ( << this is the part i need help on. How do i store the temperature here so i can access it outside the scope of the for loop)
}