Connect Different Package Classes in Java | Java Tutorial Videos

This Java Tutorial Videos”Connect Different Package Classes in Java” is explaining how to access one class members from another class using import statement and how can we prove programatically, import statement doesn’t load the class in java.


Connect Different Package Classes:

  • Define a class belongs to ‘p1’ package.
  • class must be public (to access from outside package)
  • We can connect classes using import statement.


  • Define class in another package ‘p2’.




  • ‘import’ statement doesn’t load the class directly.
  • It creates only internal pointer to package or class.
  • ‘import’ statement only loads the class at run time, on use.
  • Un used classes will not be loaded into JVM.
  • As a java programmer, we can analyze whether a class is loading or not into JVM, we need to define a static block.
  • Static block executes implicitly at the time of class loading.




Share this