-3

In java we import packages to the classes.when we accessing some thing from a different package we have to import that package to our working package.like,

  • java util.*;
  • java io.*;

But we never import java lang package.Why is that?what is the specialty in java lang package.

  • It is auto imported https://stackoverflow.com/questions/2073680/why-autoimport-only-java-lang-package – Thiyagu Jul 10 '18 at 04:25
  • 2
    @ThilanRavindu your question is entirely reasonable: it is non-obvious why it should be so. It has just been asked many times before. – Andy Turner Jul 10 '18 at 05:46

2 Answers2

7

Because:

Code in a compilation unit ... automatically imports all of the public types declared in the predefined package java.lang.

Source: Java Language Specification #7

user207421
  • 305,947
  • 44
  • 307
  • 483
-1

Java.lang package is imported by default. If you check the documentation, then you'd see you use mostly half of it blindly.

Documentation: https://www.cs.mun.ca/java-api-1.5/api/java/lang/package-summary.html

Source: http://www.cafeaulait.org/course/week4/31.html

Mert Karakas
  • 178
  • 1
  • 4
  • 22