J
JSR
If class TestPackage and DefPack are in 2 separate files, how can we
access DefPack from TestPackage?
Note -
1. TestPackage is in package testapps and DefPack is in the default
package space. This is the problem.
2. If I were to comment out the package statement within
TestPackage.java, this example would compile.
3. I need to be able to compile with the pacakge specifications being
the way they are.
// Compilation unit - TestPackage.java
package testapps;
public class TestPackage {
public static void main(String[] args) {
new DefPack();
}
}
// Compilation unit - DefPack.java
public class DefPack {
public DefPack() {
System.out.println("DefPack created");
}
}
access DefPack from TestPackage?
Note -
1. TestPackage is in package testapps and DefPack is in the default
package space. This is the problem.
2. If I were to comment out the package statement within
TestPackage.java, this example would compile.
3. I need to be able to compile with the pacakge specifications being
the way they are.
// Compilation unit - TestPackage.java
package testapps;
public class TestPackage {
public static void main(String[] args) {
new DefPack();
}
}
// Compilation unit - DefPack.java
public class DefPack {
public DefPack() {
System.out.println("DefPack created");
}
}