wood burning stoves*
The moose likes Beginning Java and the fly likes why they are no need to import? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "why they are no need to import?" Watch "why they are no need to import?" New topic
Author

why they are no need to import?

Supun Lakshan Dissanayake
Ranch Hand

Joined: Oct 26, 2012
Posts: 132

To use classes in java packages we do import the whole package or necessary classes.
But we NEVER import some classes like String, Integer, Double, Object.
How can we use them without import them?


Are you better than me? Then please show me my mistakes..
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4523
    
    5

Read about it in The Java™ Language Specification.
Every compilation unit implicitly imports every public type name declared in the predefined package java.lang, as if the declaration import java.lang.*; appeared at the beginning of each compilation unit immediately after any package statement. As a result, the names of all those types are available as simple names in every compilation unit.


luck, db
There are no new questions, but there may be new answers.
vinay chaturvedi
Greenhorn

Joined: Jan 16, 2012
Posts: 14
The java classes such as String, Number, StringBuffer, StringBuilder, Object, etc. are present in package "java.lang". In every java class this java.lang package is by default imported.
Hence all these classes are available in a class.
Supun Lakshan Dissanayake
Ranch Hand

Joined: Oct 26, 2012
Posts: 132

Thanks Guys!! problem resolved.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: why they are no need to import?
 
Similar Threads
Unable to set CLASSPATH in Linux-based OS
Import or inline?
isn't interface support inheritance
static import