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 6117063
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T15:16:40+00:00 2026-05-23T15:16:40+00:00

I created a storage class and use to as the data type for my

  • 0

I created a storage class and use to as the data type for my arraylist/Linked list.

private LinkedList bid_history;

I have initialised this in my constructure as

bid_history=new LinkedList <Bid_History> ();

I add new items to the list using add as illustrated below

bid_history.add(new Bid_History(bid_count,unit_price,bid_success));

After ‘n’ iterations I checked the contents of the list and found out that the list has ‘n’ elements but they were the same. i.e. the last element i added occupied the entire list. It is as if i added a reference variable to the list?

Any idea where I might have made a mistake? I also used an arraylist, the same problem. I am guessing I did something wrong with access specifiers! but I am out of ideas…..

—-Added ——-
I use a recursive function

bid()
{
   int bid,quantity;
        bid_success=false;
        bid_count++;
        System.out.println("Starting to bid, Bid ID:"+bid_count);
        quantity=(int)(rated_power*duration/60);
        if(bid_history.isEmpty())
        {
            unit_price=10;
        }
        else
        {
            unit_price++;
        }
        bid=unit_price*quantity;
        //Sending the calculated bid
        send_res(unit_price,quantity,500);
        long startTimeMs = System.currentTimeMillis( );
        System.out.println("Time:"+startTimeMs);
        while(!(System.currentTimeMillis( )>(startTimeMs+2000)));
        System.out.println("Time at end:"+System.currentTimeMillis( ));

        bid_history.add(new Bid_History(bid_count,unit_price,bid_success));

        if(bid_success!=true)
        {
            bid();
        }
}

the printing code is as follows

int count=0,size;
size=bid_history.size();
while(count<size)
System.out.println(((Bid_History)bid_history.get(count++)).getBid_amount());
  • 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-23T15:16:40+00:00Added an answer on May 23, 2026 at 3:16 pm

    Another possibility is that BidHistory(count, price, success) is not doing the right job and not setting the right fields. I don’t want to guess, but it might be that instead of having fields in BidHistory you are using static count/price/success fields in the class.

    The constructor should look like (“this.” is important):

    public BidHistory(int count, float price, boolean success) {
        this.count = count;
        this.price = price;
        this.success = success;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My application makes use of the RijndaelManaged class to encrypt data. As a part
In my Android application I have created an SVG image converter class. It parses
I use more than one class and I need a... lets say Global storage
What happens to the files created by Isolated Storage when the OOB app is
Created .NET WCF service, tested it - works. Generated schemas from Data and service
I created a Rails application normally. Then created the scaffold for an event class.
I have a stored procedure in SQL Server that returns some data via a
I'm new to OOD so I have a question about the use of classes
I have an existing application in C++ with a custom ArrayBase class that manages
I generated this class using SQLMetal.exe. It is very bindable at runtime, but if

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.