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

The Archive Base Latest Questions

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

I’d like to start out saying Stack Overflow has been a huge help, just

  • 0

I’d like to start out saying Stack Overflow has been a huge help, just from looking up others’ questions, but for this problem I had a hard time finding a solution because it was difficult to word a question.

I’m making a 2D platformer perspective shooting game in Java, and so I have a set of functions that create bullets. Example:

public void CreateShot01(x, y, angle, velocity, bulletID, delay){
/*...will do a bunch of stuff ultimately creating a object in the Projectiles[]    
array, which will be drawn on screen from the Board Object/Class*/
}

What’s inside that function isn’t the problem. I want to have this and other similiar functions availible to multiple classes, basically for any class that needs shooting. I don’t want to copy paste this function into every class that uses it. So I it would help to put all the functions in a separate class BulletHandler that will be will be standard.

But how do I refer to those functions from all the classes that need them. I’m not sure if the thing to use is:

-import? Seems like the most logical solution, but how do you import your own stuff?

-extends? AFAIK, this involves a super class and overwriting functions, not what I need

What is the best way to go about this?

I wasn’t sure what to information to supply so just mention it if there’s anything that needs to be added and I’ll do that right away.

  • 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-23T12:16:28+00:00Added an answer on May 23, 2026 at 12:16 pm

    You are confusing terms.

    Import is just for making reference to a file in another package, without having to add all of its package hierarchy in the code. Nothing more.

    As long as you tell, it is a classic example of subclassing (‘extends’). Create a “father” class that implements shoot(); all your objects that shoot extend from it. They just need to call to shoot() to use it, without having to provide a different implementation (unless you want to).

    Of course, there may be issues (what happens if there are two methods, and the classes that use any of them do not overlap?), but apart from that you should go with extending a main class.

    BTW, add a tag of “homework”


    Added to answer to the comments from the poster:

    Check abstract classes. They mean that they cannot be instantiated (you can not make a “new” of them) and that they can have some abstract methods of which you know the signature (parameters, return type) but don’t provide implementation. You can have other methods fully implemented.

    Also, regular “non abstract” classes can be extended and new methods added to them… please go back to the Java basics to tune your concepts (do not worry, all of us go through the pattern of learning-trying-going back to learn now that we know what it means).

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

Sidebar

Related Questions

For some reason, after submitting a string like this Jack’s Spindle from a text
I've got a string that has curly quotes in it. I'd like to replace
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have text I am displaying in SIlverlight that is coming from a CMS
I want to count how many characters a certain string has in PHP, but
link Im having trouble converting the html entites into html characters, (&# 8217;) i
Does anyone know how can I replace this 2 symbol below from the string
I have some data like this: 1 2 3 4 5 9 2 6
I have a bunch of posts stored in text files formatted in yaml/textile (from
I have a text area in my form which accepts all possible characters from

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.