• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

importing java.lang

 
Omkar Shetkar
Ranch Hand
Posts: 74
Eclipse IDE Java Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?

Regards
Omkar V S
 
Ian Edwards
Ranch Hand
Posts: 107
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 190
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes. You need not import java.lang as Java does it automatically for you. There is no harm even if you import that explicitly.
 
Omkar Shetkar
Ranch Hand
Posts: 74
Eclipse IDE Java Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But I want to know how Java do that?
 
Paul Clapham
Sheriff
Pie
Posts: 20164
24
MySQL Database
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's done by special-case programming in the compiler.
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic