Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint

Java Packages

If you are developing an application that consists of different parts, you may want to organize your classes to retain maintainability. With Java, you can group related classes or classes with similar functionality in packages. For example, standard Java classes come in packages. Java core classes are in the java.lang package. All classes for performing input and output operations are members of the java.io package, and so on. If a package needs to be organized in more detail, you can create packages that share part of the name of the former. For example, the Java class library comes with the java.lang.annotation and java.lang.reflect packages. However, mind you that sharing part of the name does not make two packages related. The java.lang package and the java.lang.reflect package are different packages.

Package names that start with java are reserved for the core libraries. Consequently, you cannot create a package that starts with the word java. You can compile classes that belong to such a package, but you cannot run them.


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint