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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T14:33:57+00:00 2026-06-10T14:33:57+00:00

Try this piece of code. It compiles. import java.io.*; import java.io.*; import java.io.*; import

  • 0

Try this piece of code. It compiles.

import java.io.*;
import java.io.*;
import java.io.*;

import java.util.*;
import java.util.*;
import java.util.*;

import javax.swing.*;
import javax.swing.*;
import javax.swing.*;


public class ImportMultipleTimes
{
   public static void main(String[] args)
   {
      System.out.println("3 packages imported multiples times in the same class.");
   }
}

Does the compiler simply ignore the additional import statements?

  • 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-10T14:33:59+00:00Added an answer on June 10, 2026 at 2:33 pm

    Yes, it will be considered redundant by the compiler, as specified by the JLS 7.5.2:

    Two or more type-import-on-demand declarations in the same compilation unit may name the same type or package. All but one of these declarations are considered redundant; the effect is as if that type was imported only once.

    Note:

    • “type-import-on-demand” is a package import: import somepackage.*;
    • the same applies for single-type-import : “If two single-type-import declarations […] attempt to import […] the same type, […] the duplicate declaration is ignored.”
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Try this code - import java.io.StringReader; public class StringReaderTest { public static void main(String[]
Try this piece of code - public class WhitespaceTest { public static void main(String[]
I'm using this piece of code to try and save an image to the
I have this seemingly innocent piece of code: void generate_heightmap(float **terrain) { } int
Consider this piece of code: #include <vector> #include <iostream> using namespace std; class Base
when I try to compile this piece of code prod [] = 1 prod
I've got an enum like this in an old piece of code: [Flags] public
Try this piece of code. Why does getValueB() return 1 instead of 2? After
In this piece of code (runs in a unit test under debugging) try {
When I try to compile the piece of code below, I get this warning:

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.