
- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
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
Accessing a Java class in other 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 wildcard (*). For example −
import payroll.*;
- The class itself can be imported using the import keyword. For example −
import payroll.Employee;
- Related Questions & Answers
- How to use classes in other package in Java
- Display the package name of a class in Java
- Accessing protected members in a C++ derived class
- What is the package for String Class in Java?
- What would getPackage() return for a class in unnamed package in Java?
- Can I define more than one public class in a Java package?
- What is a predefined package in Java?
- Another method other than a constructor in a JavaScript class?
- How to access Java package from another package
- Accessing variables of two interfaces, which are same from an implementing class in java?
- Accessing Kotlin extension functions from Java
- overriding method different package in java
- Check for the availability of a package in Java
- How to resolve "Could not find or load main class package" in Java?
- How to put two public classes in a Java package.
Advertisements