+ 1
Package in java
I have read something that makes me confuse which is all about the sub packages in java. Here is the statement "A package inside another package is known as sub package. For example If I create a package inside letmecalculate package then that will be called sub package. Lets say I have created another package inside letmecalculate and the sub package name is multiply. So if I create a class in this subpackage it should have this package declaration in the beginning: package letmecalculate.multiply; ". I have tried it in my eclipse ide but it didn't work . Guys please help me to resolved my confusion.
1 Odpowiedź
+ 1
The package declaration you gave is perfect:
package letmecalculate.multiply;
Here are some other things to verify:
- Make sure you mirror your package in your file system. If you had a public Multiplication class in there, it should be in a file ending with the path /letmecalculate/multiply/Multiplication.java.
- Make sure Eclipse is compiling from above that letmecalculate path. The underlying javac command needs to run from a directory just above the root package's directory.
If you see compilation errors, share them here.
Check out this package tutorial that uses Eclipse. He points out how to make the folders mirror your package so it compiles:
https://www.youtube.com/watch?v=sbo-D3P6GNg