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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T10:14:58+00:00 2026-06-09T10:14:58+00:00

I have never encountered this sort of problem in Java before. All this code

  • 0

I have never encountered this sort of problem in Java before. All this code and the full project may be found at my GitHub. I have a Snowflake class with class hierarchy:

Snowflake extends SolidRectangle extends Movable extends Drawable extends Object

The following two code sections in my Snowflake class produce different graphical results in my game:

//In Snowflake class
public void decay()
{
    age++;
    color = randomSnowflakeColor();
    if(age == 5)
    {
        super.remove();
        Snowflake.Mempool.returnSnowflake(this);
    }
}

and

//In Snowflake class
public void decay()
{
    age++;
    color = randomSnowflakeColor();
    if(age == 5)
    {
        this.remove();
    }

public void remove()
{
    super.remove();
    Snowflake.Mempool.returnSnowflake(this);
}

Neither SolidRectangle nor Movable overrides the remove method, but Drawable does, with the following implementation:

//In Drawable class
public void remove()
{
    game.remove(this);
}

and GameContent game has the following implementation:

//In GameContent class
public synchronized void remove(Drawable drawable)
{
    removeQueue.add(drawable);
}

I will spare you the details of removeQueue, suffice it to say that it is exactly what you expect.

As for Snowflake.Mempool, I know manual memory management isn’t usually part of a Java programmer’s day, but I found there was too much overhead in creating and garbage collecting these snowflakes, so I thought I would just reuse old snowflakes to avoid this overhead. Please don’t get distracted by this. My question is about how the two first code blocks could possibly be different, when they appear to be functionally equivalent.

So, how can the two first code block be producing different results?

  • 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-09T10:15:00+00:00Added an answer on June 9, 2026 at 10:15 am

    While the same result is expected when calling decay(), different behaviour of your class may result when remove() is called from elsewhere in the code.

    Using your IDE, search for usages of the remove() method and all may be revealed.

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

Sidebar

Related Questions

This problem is bizarre. I have never encountered anything like it before. I am
I am encountering a problem which I have never encountered before. I am working
I'm working someone else's code. I've never encountered something like this before: return [[[NSObject
This is an oddball issue I've encountered (and probably have seen before but never
I have never encountered an error like this before. I was using prepared statements
I can honestly say I've never encountered this one before: I have two .ascx
I have never programed in bash before. I am reading all the files that
I have never used Foxpro before. Can you convert the following Foxpro code into
Since I've never encountered this kind of problem I thought about making language parser
Ok, folks. I've never encountered this before and it boggles the mind and is

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.