Avoiding Confusion about an Import Statement

Every source file in Java (.java file) contains one class. You can bundle a set of related classes into a package. Java provides “import” keyword, which is used to establish a reference to a class in a different package.

There are couple of ways in which you can use “import”statement.

(a) Use a specific class name in “import” statement:

  import myPackage.myClass;	// myPackage-Package,myClass-Class

(b) OR you can use wild card “import” statement like :

  import myPackage.*; 	// import all the classes

The second approach is simple, because it imports all the classes in the specified package. There are no disadvantages of using wild card “import” statement with respect to compile time, run time, or code size, etc.

The only problem where we cannot use “import” is the place where we want to import two classes of same name from two different packages. In this situation, you can refer to the classes using full qualifier, i.e.


Share the Post:
Share on facebook
Share on twitter
Share on linkedin


The Latest

microsoft careers

Top Careers at Microsoft

Microsoft has gained its position as one of the top companies in the world, and Microsoft careers are flourishing. This multinational company is efficiently developing popular software and computers with other consumer electronics. It is a dream come true for so many people to acquire a high paid, high-prestige job

your company's audio

4 Areas of Your Company Where Your Audio Really Matters

Your company probably relies on audio more than you realize. Whether you’re creating a spoken text message to a colleague or giving a speech, you want your audio to shine. Otherwise, you could cause avoidable friction points and potentially hurt your brand reputation. For example, let’s say you create a

chrome os developer mode

How to Turn on Chrome OS Developer Mode

Google’s Chrome OS is a popular operating system that is widely used on Chromebooks and other devices. While it is designed to be simple and user-friendly, there are times when users may want to access additional features and functionality. One way to do this is by turning on Chrome OS