|
|
Home J2EE Concepts JMS Java Language Contact Back Next Bookmark this Page |
Some useful tips related to:
|
Importing Classes & PackagesIf you're wondering what does importing a class mean, then it simply means making a class available to your current class. Java provides import statement to import classes. If you don't use import; then also you can access any class from any package in your code (if allowed by corresponding access specifiers). You'll have to refer to fully qualified name of the class throughout your code. For e.g. if there is no import statement for myPackage1.myPackage2.myClass; then you would need to write myPackage1.myPackage2.myClass everytime you want to use myClass in your code. So, import statement actually provides convenience in terms of writing code as well as reviewing code. Following points are worth keeping in mind: |
|
If you don't use import; then also you can access any class from any package in your code (if allowed by corresponding access specifiers). You'll have to refer to fully qualified name of the class throughout your code. For e.g. if there is no import statement for myPackage1.myPackage2.myClass; then you would need to write myPackage1.myPackage2.myClass everytime you want to use myClass in your code. So, import statement actually provides convenience in terms of writing code as well as reviewing code. |
|
|
|
|