0

I am fairly new at programming (especially in java) and had a question regarding inheritance in java. I understand the syntax for inheritance (class newPlayer extends Player) but am wondering if all the source code or something has to be in the same folder or imported or something for java to detect it.

Im working on a school assignment and had to download the .java class file and inherit from it. I am also using eclipse to work on this project. Right now I'm just getting the message that I need to create a Player class. hope this all makes sense!! ANy help would be much appreciated.

3
  • What is the exact message you are getting? Can you post a SSCCE? Commented Oct 25, 2013 at 17:51
  • 1
    based on class newPlayer extends Player it kind of seems like you want to create an instance of Player, but maybe not. If you do you just have to say Player newPlayer = new Player(); But that wont get rid of your error. Commented Oct 25, 2013 at 17:53
  • [Your question has been answered here.][1] [1]: stackoverflow.com/questions/7869006/… Commented Oct 25, 2013 at 17:59

3 Answers 3

1

No, it has to only be on project's class path for the compiler and eclipse to see it.

Sign up to request clarification or add additional context in comments.

1 Comment

Is there a tutorial for doing this? This is my first time doing this and I am a wee bit lost....
1

'Ctrl+Shift o' if its in your path this will add the import.

If your new be careful of extend v implements.

Comments

0

It can be done both ways. If class Player is not in the same package as newPlayer, then you need an import statement. If they are in the same package you don't need one.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.