Breaking News: Grepper is joining You.com. Read the official announcement!
Check it out

Can you import same package or class twice in your class?

Pragya Keshap answered on February 4, 2023 Popularity 2/10 Helpfulness 1/10

Contents


More Related Answers

  • do i have to import files from the same package in java
  • java import two classes with same name
  • python multiple imports from same module
  • import class from package java

  • Can you import same package or class twice in your class?

    0

    YES

    If we import same package multiple times in a class, compiler

    includes it only once. So neither JVM nor Compiler gives any

    error/warning on including a package multiple times.

    If you have two classes with same name, then you may get name

    collision on importing the class erroneously.

    JVM internally loads the class only one time

    https://www.tutorialspoint.com/can-i-import-same-package-twice-will-jvm-load-the-package-twice-at-runtime#:~:text=Yes%2C%20you%20can%20import%20a,loads%20the%20class%20only%20once.

    Popularity 2/10 Helpfulness 1/10 Language java
    Source: Grepper
    Link to this answer
    Share Copy Link
    Contributed on Feb 04 2023
    Pragya Keshap
    0 Answers  Avg Quality 2/10


    X

    Continue with Google

    By continuing, I agree that I have read and agree to Greppers's Terms of Service and Privacy Policy.
    X
    Grepper Account Login Required

    Oops, You will need to install Grepper and log-in to perform this action.