Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

importing java.lang

 
Omkar Shetkar
Ranch Hand
Posts: 75
IntelliJ IDE Java Ubuntu
  • 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
  • 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
  • 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: 75
IntelliJ IDE Java Ubuntu
  • 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: 20945
31
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's done by special-case programming in the compiler.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic