Using Netbeans, I want to put a package into another package. For example in Visual Studio 2008, I can have folder called "Nodes", and another folder inside of Nodes called "Expressions". How do I do this in Netbeans? I think a package in Java is equivalent to a folder in C#.
There is no concept of package with in package. Each package is separate namespace.
To import the java package into a class, we need to use the java import keyword which is used to access the package and its classes into the java program. Use import to access built-in and user-defined packages into your java source file to refer to a class in another package by directly using its name.
In Java, it is possible to define a class within another class, such classes are known as nested classes.
You cannot put package declaration twice in the same class. The package statement must be the first line in the source file. There can be only one package statement in each source file, and it applies to all types in the file.
For a package within a package, put the parent name, a period, and then the name of the child's package like so: Nodes.Expressions
.
It will appear as it's own separate package in an IDE perhaps, but the folder hierarchy will be as you desire: Nodes/Expressions/[classes etc]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With