File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes importing java.lang Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "importing java.lang" Watch "importing java.lang" New topic

importing java.lang

Omkar Shetkar
Ranch Hand

Joined: Jun 22, 2006
Posts: 74

Hi All,

I have got a doubt regarding very basic fact of Java i.e., why we need not import java.lang package? What is the mechanism in Java which makes any program to have access to the default package?

Omkar V S
Ian Edwards
Ranch Hand

Joined: Aug 14, 2006
Posts: 107
There's nothing stopping you importing the java.lang package yourself - its just not required as the compiler will automatically do it for you.

This package provides classes that are fundamental to the language. You won't get far without it.
Swapnil Sonawane
Ranch Hand

Joined: Jan 02, 2008
Posts: 190
Yes. You need not import java.lang as Java does it automatically for you. There is no harm even if you import that explicitly.

Swapnil S. Sonawane<br /> <br />B.Tech (Expected May 2009)<br />Computer Science, NIT Durgapur, India<br />SCJA 1.0
Omkar Shetkar
Ranch Hand

Joined: Jun 22, 2006
Posts: 74

But I want to know how Java do that?
Paul Clapham

Joined: Oct 14, 2005
Posts: 19973

It's done by special-case programming in the compiler.
I agree. Here's the link:
subject: importing java.lang
jQuery in Action, 3rd edition