Meaningless Drivel is fun!*
The moose likes Beginning Java and the fly likes import java.lang.*; Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "import java.lang.*;" Watch "import java.lang.*;" New topic
Author

import java.lang.*;

Gary Ba
Ranch Hand

Joined: Oct 23, 2009
Posts: 150

I have a question about using an Array. I read somewhere that by default java.lang.* is already imported in any classes thus there is no need to add it on top. I am using static method Array.getLength() but how come I need to import java.lang.reflect.Array; ? Can anyone please explain a reason for this?

Thank you,
Garry


star chaser..
Ireneusz Kordal
Ranch Hand

Joined: Jun 21, 2008
Posts: 423
java.lang.* importst only java.lang package.
java.lang.reflect is a completely different package.
They only share part of their name, but they are completely different,
they could be even stored in other jar files in different directories on the disk.

Think about package names like a directories on the disc, and about import clause like a 'dir' command
- dir /java/lang/* lists content only only of /java/lang, to list content of /java/lang/reflect
you must run another dir command.
Gary Ba
Ranch Hand

Joined: Oct 23, 2009
Posts: 150

K. I looked at the API and saw on top that the two are from two different packages.

Thank you for the knowledge!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: import java.lang.*;
 
Similar Threads
Language Fundamentals
Math method
Searching and replacing text in a string
having an string need to take out the integer!
Call a static method from JSP