Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8814413
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T04:07:02+00:00 2026-06-14T04:07:02+00:00

I need to create 3 instances of my temperature class. I can do this

  • 0

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) 
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T04:07:03+00:00Added an answer on June 14, 2026 at 4:07 am
    List<Temperature> temperatures = new ArrayList<Temperature>();
    for (int i = 0; i < 3; ++i) {
        Temperature t = new Temperature();
        t.setDegrees(user input) ;
        temperatures.add(t);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need create clone repository. but I do not know where can I get
I have a C++ class that I need to create several instances of in
I need to create at runtime instances of a class that uses generics, like
I need to create many instances of a specific class in a single page,
I need to create a global Arraylist consisting Instances of my custom class 'Book'
I have some part imports that I need to create multiple instances of. By
I need to create two instances of two classes inside a view controller that
We need to create & destroy instances of QApplication, as we want to use
Why do i need to create an instance of Random class, if i want
I need this roadmap of a Hibernate managed object instance. First, I create an

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.