Reputation: 39
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.
Upvotes: 0
Views: 4409
Reputation: 345
'Ctrl+Shift o' if its in your path this will add the import.
If your new be careful of extend v implements.
Upvotes: 1
Reputation: 3728
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.
Upvotes: 0
Reputation: 32507
No, it has to only be on project's class path for the compiler and eclipse to see it.
Upvotes: 1