Okay, so I am trying to wrap my head around how to get stuff done with Java (I come from C++, Python, PHP etc.). I'm quite familiar with the language itself and OO principles, but less so familiar with building projects, stitching the dependencies together, and other aspects of the ritual and repetition that surrounds putting together a functioning Java program.
If you have resources to suggest (good tutorials etc.), I wholeheartedly encourage you to do so.
My question is this:
I have a new Eclipse project. I make a class, let's say Guitar, that I want to use in another class in the same project, Musician (this is where my main() method resides). How do I import and use Guitar in the source for the Musician class?
There's got to be something obvious I'm overlooking here, but I've tried a bunch of different things to no avail. Just tangling myself up into a mess. :)
Thanks for your help.
You can just use Guitar in your code and press ctrl + shift + O to add the import. Alternatively, you can highlight the class reference in the code and Eclipse will ask if you want to import it, or you could simply type the import yourself: import com.foo.Guitar; at the top of the class.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With