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 9021263
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T05:12:58+00:00 2026-06-16T05:12:58+00:00

I was working on a little Java program and was using arrays so I

  • 0

I was working on a little Java program and was using arrays so I had done:

import java.util.Arrays;

Later I started expanding on what I had previously done and decided I wanted to get input from the user, so at that point I added:

import java.util.Scanner;

Now a thought occurred. I know that I could just do:

import java.util.*

Then I’d just need 1 import line instead of two (or however many I end up needing), but does the wildcard in the import mean that it will import everything from that package regardless of if it’s needed or not, or will only the selective functionality be pulled?

My instinct here is to write more code and only include the packages I know I need, but if it doesn’t make a difference why would anyone import more levels/packages then they need to? (I’d rather just be lazy and write less code)

  • 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-06-16T05:12:59+00:00Added an answer on June 16, 2026 at 5:12 am

    Be clear about what import is doing. It does NOT mean loading .class files and byte code.

    All import does is allow you to save typing by using short class names.

    So if you use java.sql.PreparedStatement in your code, you get to use PreparedStatement when you import java.sql.PreparedStatement. You can write Java code forever without using a single import statement. You’ll just have to spell out all the fully-resolved class names.

    And the class loader will still bring in byte code from .class files on first use at runtime.

    It saves you keystrokes. That’s all.

    It has nothing to do with class loading.

    Personally, I prefer to avoid the * notation. I spell each and every import out. I think it documents my intent better. My IDE is IntelliJ, so I ask it to insert imports on the fly.

    Laziness is usually a virtue for developers, but not in this case. Spell them out and have your IDE insert them for you individually.

    if you type

    import java.util.*;
    

    you’ll get to refer to Scanner and List by their short names.

    But if you want to do the same for FutureTask and LinkedBlockingQueue you’ll have to have this:

    import java.util.concurrent.*;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on a little program to make my life easier when using Microsoft
I'm working on a class project to build a little Connect4 game in Java.
I've started working a little bit with lift+scala+mongorecord but I found a small annoyance
I'm working on a Java program, and it's been over a year since the
I am creating a GUI using Java. This GUI launches a program from the
I'm trying to make a little program in Java, I need it to remove
I am working on a little Java game, leaning on the classic Asteroids. In
I'm working on a little server app with Java. So, I'm getting informations from
i have been trying to create a little java program that all it does
I am trying to get a little test working in Java. I have two

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.