C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML
Default package: In Eclipse we specify the default package. We can then import other packages with the import keyword into this.
Note: We do not need to use the "import" keyword. We can specify a type like testPackage.Test but this is hard to type.
Example package: Java
package testPackage;
public class Test {
public void printName() {
// This method is in the Test class in testPackage.
System.out.println("The Dev Codes");
}
}
Example program, import keyword: Java
import testPackage.Test;
public class Program {
public static void main(String[] args) {
// Create new instance of Test from testPackage.
Test test = new Test();
// Call method.
test.printName();
}
}
Output
The Dev Codes
Example import with star:
import java.util.function.*;