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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T23:47:38+00:00 2026-06-05T23:47:38+00:00

Note: I realize that this is probably an open-ended question, so go ahead and

  • 0

Note: I realize that this is probably an open-ended question, so go ahead and flag for deletion if you feel this either doesn’t belong or has no merit.

I haven’t been working with Java (or really programming in general) for very long and most of my time is spent on learning practical application (specifically with Android). Therefore, I realize that I am very behind when it comes to conceptual issues.

My question is this: When is it appropriate to use the import 'package name'; statement instead of simply using the fully qualified class name?

I’ve seen sample code where the coder decided to use android.widget.Button vs. calling import android.widget.Button and using Button for every instance afterwards. I’m currently writing code where I know I will be using a certain class only once and I feel like using an import statement is a waste.

Any guidelines on when I should be using an import statement vs. using a fully qualified name would be much appreciated. I am not looking for a definitive answer, just some helpful tips.

  • 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-05T23:47:39+00:00Added an answer on June 5, 2026 at 11:47 pm

    The solution is simple: if you have more than 1 Button class (obviously, each in their own package) that you have to use in the same class, then use the fully qualified name. Otherwise, import the only Button class that you need.

    Generally, package import is preferred as it brings cleaner code and it makes compiler knows what class (package) to compile upfront.

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

Sidebar

Related Questions

Note, this is not a duplicate of .prop() vs .attr() ; that question refers
NOTE: This is a followup to my question here. I have a program that
I realize that this question spans many technologies, but I am only looking for
I realize that this type of question has been asked several times before but
Note: I originally asked this question about an hour ago but only recently realized
(Note: This is not a question about what is the best way with code
NOTE: This is an old question and the answers here no longer works (since
This question probably reveals my total lack of knowledge in Java. But let me
I realize that there are much more elegant ways to do this, and I
I realize this is probably a fundamental thing I should know but I am

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.