This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
I've just started to programming in Java, I’m using the book Head First Java to learn how to program. The book explains that for this moment I can use a testclass to test my created class.
My question: how does the testclass know where to find my created class when using a reference variables to access the created variables? See code examples below.
Both files compile without any problem but I fail to see how they link / work together. I'm really curious. Thank you for your time, Dutchy'91.
Welcome to CodeRanch! I added code tags to your post to make it easier to read.
In Java, all code goes in a package. If you don't specify one, it goes in the default package. Both of your classes are in the default package.
Java also has concept called a classpath. The default is class files in the current directory. You can automatically refer to classes in the classpath in the same package without doing anything.
Putting this together, it means you can refer to classes in the same directory if both are in the default package without having to do anything special. Which is a nice default! It lets people new to Java start without having to be aware of either of these concepts.