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

  • Home
  • SEARCH
  • 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 6565331
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T14:04:51+00:00 2026-05-25T14:04:51+00:00

I assume those are bacics. I’ve created 3 objects like this: for (int j

  • 0

I assume those are bacics.

I’ve created 3 objects like this:

    for (int j = 1; j < 4; j++) {
        int parkingSlot= 1 + rd.nextInt(3);
        AircraftCarrier ac= new AircraftCarrier (fc, j, parkingSlots, parkingSlots);

    }

Based on class AircraftCarrier (it’s constructor):

public AircraftCarrier (FlightControl fc, int idC, int parkingSlots, int freeParkingSlots) {
    this.kontrolaLotow = fc;
    this.id = idC;
    this.ps = parkingSlots;
    this.fps = freeParkingSlots;        
}

So i have 3 Aircraft Carriers, right? Let’s assume I need to change freeParkingSLots value for a carrier with id =2. How do I do that?

  • 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-05-25T14:04:52+00:00Added an answer on May 25, 2026 at 2:04 pm

    You created three instances but since you didn’t maintain the reference to any of them, you no longer have them. They have been sent to garbage collection.

    You need to store each instance in some collection for later access.

     List<AircraftCarrier> myList = new ArrayList<AircraftCarrier>();
     for (int j = 1; j < 4; j++) {
        int parkingSlot= 1 + rd.nextInt(3);
        AircraftCarrier ac= new AircraftCarrier (fc, j, parkingSlots, parkingSlots);
        myList.add(ac);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is one of those little detail (and possibly religious) questions. Let's assume we're
Assume you are doing something like the following List<string> myitems = new List<string> {
Assume I have a function template like this: template<class T> inline void doStuff(T* arr)
Lets assume I have created a facebook app.So all those who(Admin) have facebook fan
Update - for those of a facetious frame of mind, you can assume that
I assume this is pretty easy so here goes; I'm trying to execute these
Assume the following class: public class MyEnum: IEnumerator { private List<SomeObject> _myList = new
I'm working on 2 cases: assume I have those var: a = hello b
I have read the examples here: http://framework.zend.com/manual/en/zend.gdata.spreadsheets.html But those examples assume the spreadsheet to
Explaining it further Assume i have two strings like below I am a super

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.