01
Nov
All classes in Java belong to some package.
at the beginning of each file that contains code to a Sprite class. (The package declaration must be the first statement in the file.) If you don t include a package statement at the start of a file, the classes in the file will be members of the default package. To avoid name conflicts. By creating packages, you avoid the possibility of naming conflicts while developing applications. Let s say you re writing a program with your friend Ira. By putting all of Ira s classes into a package called ira , and your classes into your own package, there won t be any problems if you both pick the same names for classes. For example, if each package has a class Shark, the two versions can be distinguished using the fully qualified name: ira.Shark shark1; // Shark class in package ira jon.Shark shark2; // Shark class in package jon For visibility. The classes in a package have direct access to all variables for which access isn t specified (for example, public, private, protected), and to all classes within the package. You can use this default level of access to make the classes in a package more efficient, by eliminating unnecessary accessor methods while keeping these variables visible only within a package. Only the public classes and interfaces of a package are accessible outside of the package. Thus, you can create helper classes that are non-public, and invisible outside package boundaries. Nested Packages and Directory Structure A package can be nested within another package. The declaration package game.sprite; denotes a package sprite in a package called game . In a similar way, the packages of the Java API, such as java.lang and java.awt, are subpackages of the enclosing java package. Thus, packages are organized in hierarchical fashion. For many installations, the package hierarchy corresponds to the directory structure of the packages. Thus, class files of the package game belong in some directory called game/, while class files of package game.sprite are found in the directory game/sprite/. If you don t state the package that a source file belongs to, it is considered part of the default package, which corresponds to the directory that the file is in. When you re developing a game, it s easiest to keep your files as part of the default package. But once you ve built up a library of classes you ll use in future games, you can arrange these class files in packages and import them when necessary. Now, let s move on to threads. Using Threads
Note: If you are looking for best hosting provider to host and run your tomcat application check Astra tomcat hosting services
