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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T11:04:29+00:00 2026-05-31T11:04:29+00:00

I have a list an element defined as such: public List<Bullet> Bullets; Bullet newBullet

  • 0

I have a list an element defined as such:

public List<Bullet> Bullets;
Bullet newBullet = new Bullet(0, 0, 0, 0, 0, 0, 0, 0);

When an onscreen button is pressed I run:

 newBullet.setProperties((int)(CannonCenterX + CannonEndX), (int)(CannonCenterY + CannonEndY), (int)(25*scaleX), (int)(25*scaleY), CannonEndX, CannonEndY, screenWidth, screenHeight);
 Bullets.add(newBullet);

That should change the properties of the newBullet element, and add a copy of it to the Bullet List. However once I do that the application crashes.

The threading part here:

// try locking the canvas for exclusive pixel editing on the surface
        try {
            canvas = this.surfaceHolder.lockCanvas();
            synchronized (surfaceHolder) {
                // update game state
                this.gamePanel.update();

                // draws the canvas on the panel
                this.gamePanel.onDraw(canvas);
            }
        } finally {
            // in case of an exception the surface is not left in
            // an inconsistent state
            if (canvas != null) {
                surfaceHolder.unlockCanvasAndPost(canvas);
            }
        }   // end finally   

Generates an exception and the program closes. I have no idea why adding an already generated element to a list would crash the program. Any help is appreciated.

-Nathan

  • 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-31T11:04:31+00:00Added an answer on May 31, 2026 at 11:04 am

    You need to create the list:

    public List<Bullet> Bullets = new ArrayList<Bullet>();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a List where element is: struct element { double priority; int value;
I have a page with a list element attached. How do I determine the
I have a list of lists that looks like this: x[[state]][[year]] . Each element
OK, I have a list ( <ul> ) then inside each <li> element I
I have an event handler that will remove an element from a list of
I have to search through a list and replace all occurrences of one element
I have a list called list_ds of a custom-defined data structure in my OCaml
I have defined a type and a function: type element = ... let merge
I have the following problem: list.c struct nmlist_element_s { void *data; struct nmlist_element_s *next;
I have list elements like so: <li> <strong style=color: #BBB;>1</strong> <a href=>Matt</a> <b>4 days

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.