import in java

Previous
Next

Accessing the classes from other packages:

  • We need to import other packages to access their classes.

Connecting Different Package Classes:

  1. ‘import’ statement is used to connect the classes of different packages.
  2. We can access only public class functionality from other package.
  3. Only public constructor is allowed to instantiate class from another package.
  4. Only public members are visible to access from outside package.

import:

  • It is a reserved word used to connect classes of different packages.
  • Import statement creates an internal pointer either “to package” or “to class”.
  • Import statement loads the class only when we access its functionality.
Previous
Next

Add Comment

Courses Enquiry Form