on page 97, it's written:
" You create your own package using the package keyword (this must be the first non-comment statement in the file) followed by the name of your package (all lowercase) "
This statement seems to be more advice than rule. The requirement of having package keyword as the first non-comment statement in the file seems dispensable. A source file having multiple package declarations, with the respective code in a pair of curly braces, seems to work fine.
Compilation of a source file with two package keywords (with their respective code) seems to create two folders, distributing the respective class files to them. The compiler doesn't complain if in the same source file, first a class is defined, then two packages are defined, all with their respective codes in curly braces.
Even package nesting seems to work, with the nesting scheme being manifested in the directory scheme created on the file system.
on page 97, it's written: " You create your own package using the package keyword (this must be the first non-comment statement in the file) followed by the name of your package (all lowercase) "
This statement seems to be more advice than rule. The requirement of having package keyword as the first non-comment statement in the file seems dispensable. A source file having multiple package declarations, with the respective code in a pair of curly braces, seems to work fine.
Compilation of a source file with two package keywords (with their respective code) seems to create two folders, distributing the respective class files to them. The compiler doesn't complain if in the same source file, first a class is defined, then two packages are defined, all with their respective codes in curly braces.
Even package nesting seems to work, with the nesting scheme being manifested in the directory scheme created on the file system.