Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6943289
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T13:08:10+00:00 2026-05-27T13:08:10+00:00

Possible Duplicate: Why is using a wild card with a Java import statement bad?

  • 0

Possible Duplicate:
Why is using a wild card with a Java import statement bad?

Ex. 1

import javax.swing.*

JFrame f = new JFrame()

Ex. 2

import javax.swing.JFrame

JFrame f = new JFrame()

Is there any efficiency gain (even the slightest and minimal) in adapting 2) instead of 1) ? How does java does the referencing of packages internally?

The first time the compiler comes across the word JFrame, I presume that it should search for JFrame in complete swing.* package in case of 1)..Else if in case 2), it might probably get hold of the class directly by some indexing or may be key value hashing? So why is this not considered an efficiency gain even if it is tiny? (Please correct me if my presumptions about the internals are wrong)

EDIT :

Sorry for the duplicate.. Answer at Why is using a wild card with a Java import statement bad?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T13:08:10+00:00Added an answer on May 27, 2026 at 1:08 pm

    There is no runtime penalty for using import javax.swing.*
    and import javax.swing.JFrame in Java. The only different is in compile time, the import package.* will search for whole package to find the correct class’ information.

    The Single-Type-Import (e.g., import javax.swing.JFrame) increases the readability of the program and it will be very clear which classes have been used.

    The Type-Import-on-Demand (e.g. import javax.swing.*) causes the simple names of all public types declared in the package javax.swing to be available within the class and interface declarations of the compilation unit.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Using java to create a web browser Is there any way to
Possible Duplicate: Using LGPL library in a commercial Java application Hello guys! There is
Possible Duplicate: How do you send email from a Java app using Gmail? How
Possible Duplicate: using mysql_close() Are mysql_close and pg_close required ? In some script there
Possible Duplicate: Are there gotchas using varargs with reference parameters Hi, I have a
Possible Duplicate: Tab behavior using jQuery Imagine that there are many text boxes in
Possible Duplicate: Using Java Lib with Scala Reserved Words I'm experimenting with Scala, and
Possible Duplicate: Using multiple cores/processors when compiling Java Can javac be configured to benefit
Possible Duplicate: Programmatically using tab character in .NET? Is there an equivalent value for
Possible Duplicate: Using 'return' in a Ruby block I'm new to Ruby, and was

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.