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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T17:10:25+00:00 2026-06-02T17:10:25+00:00

I got a linked list with a class I created but every time I

  • 0

I got a linked list with a class I created but every time I add a new instance to the list all other elements in the list gets the same data.

Here is the class I have in my list.

public class ZitEntity 
{
private int mSize;
public boolean poped;
private boolean done;
private Canvas can;
private int count;
private  static Vector2D mPosition;
private int ms;
private Bitmap Zit;

public ZitEntity(int a, int b)
{
    mSize = 20;
    poped = false;
    done = true;
    ms = 3;
    mPosition = new Vector2D(a,b);
    Zit = Bitmap.createBitmap(mSize*2, mSize*2, Bitmap.Config.ARGB_8888);
}

In the second class I create a list.

private LinkedList<ZitEntity> entityList;

and in the constructor i initiate the list.

entityList = new LinkedList<ZitEntity>();

And here is where I add a new instance to the list:

private void createEntity()
{
    Random generator = new Random();
    int a = generator.nextInt(10);
    if(a==5)
    {   
        int x = generator.nextInt(ZitGame.height-60)+20;
        int y = generator.nextInt(ZitGame.width-120)+20;
        entityList.add(new ZitEntity(x,y));
        Log.v("add entity", "new entity");
    }
}
  • 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-02T17:10:26+00:00Added an answer on June 2, 2026 at 5:10 pm

    you are declaring the mPosition as static, so every time you will get the latest position for each item

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to create a linked list, I've got it working, but I'm still
i got 3 linked list and union function a b and result are lists
I've got a structure which holds names and ages. I've made a linked-list of
Got a class that serializes into xml with XMLEncoder nicely with all the variables
I am trying to implement a linked list using following code, I got segment
----Complete Rephrasing---- I was working on a new class where each instance was essentially
I got a problem here, implementing a Sorted Doubly Linked List of first and
i have a double linked list with many list elements. so i can use
I've got a linked list of nodes that contain a string of characters. The
I've got a class somewhat like this: public class Test { private final List<ISomeType>

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.