Java package declaration
Package declaration is the first line of any Java class. It starts with the package keyword, followed by the package name. The javac and java tools search for a class on a classpath using a fully qualified class name, which is a class name with the package name appended in front of it. For example, if we put the MyApplication class in the com.packt.javapath.ch04demo package, the fully qualified name of this class will be com.packt.javapath.ch04demo.MyApplication. As you could guess, ch04demo stands for the demo code of Chapter 4. This way, we can use the same class name in different chapters, and they will not clash. That is how the package name serves the purpose of unique identification of a class on a classpath. ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access