CAN I IMPORT SAME PACKAGE/CLASS TWICE? WILL THE JVM LOAD THE PACKAGE TWICE AT RUNTIME?

Mayank Tripathi

Total Post:807

Points:4035
Posted by  Mayank Tripathi
Java 
 698  View(s)
Ratings:
Rate this:
  1. Mayank Tripathi

    Post:807

    Points:4035
    Can I import same package/class twice? Will the JVM load the package twice at runtime?

    One can import the same package or same class multiple times. Neither compiler nor JVM complains about it.But the JVM will internally load the class only once no matter how many times you import the same class

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!