![]() |
< Day Day Up > |
![]() |
Recipe 3.3 Creating Java Packages3.3.1 ProblemYou want to put your code into a Java package. 3.3.2 SolutionSelect File 3.3.3 DiscussionIn all but the most trivial projects, you usually put your Java code
into a package. To create a new package, select a project in the
Package Explorer and then select File Figure 3-6. Creating a new package![]() When the new package appears in the project, you can add classes to
it by right-clicking it and selecting New
When you access a class in another package, you must import it using that class's fully qualified name in your code: import org.cookbook.ch03.DisplayApp;public class DisplayApp { public static void main(String[] args){DisplayApp display = new DisplayApp( );display.print( );} }
|
![]() |
< Day Day Up > |
![]() |