 
  Data Structure Data Structure
 Networking Networking
 RDBMS RDBMS
 Operating System Operating System
 Java Java
 MS Excel MS Excel
 iOS iOS
 HTML HTML
 CSS CSS
 Android Android
 Python Python
 C Programming C Programming
 C++ C++
 C# C#
 MongoDB MongoDB
 MySQL MySQL
 Javascript Javascript
 PHP PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to access Java package from another package
You can understand it using an example where a Boss class is defined in payroll package.
package payroll; public class Boss {    public void payEmployee(Employee e) {       e.mailCheck();    } } if the Employee class is not in the payroll package? The Boss class must then use one of the following techniques for referring to a class in a different package.
- The fully qualified name of the class can be used. For example −
payroll.Employee
- The package can be imported using the import keyword and the wild card (*). For example −
import payroll.*;
- The class itself can be imported using the import keyword. For example −
import payroll.Employee;
A class file can contain any number of import statements. The import statements must appear after the package statement and before the class declaration.
Advertisements
 