8
Adding the studies in Java I came across a package so much that special, the java.lang
, where the author of the book mentions that we do not need to perform the import
of that package.
There’s a package special in the Java world called java.lang. This package is special because it is automatically imported. It is still possible to type this package in an import declaration, but you do not need to do That. "OCA: Oracle Certified Associate Java SE 8 Programmer I Study"
I would like to understand why only the package java.lang.*
is the only one where we do not need to import when we are developing in Java and what it has of differential with the other packages in which we need to import?
It is because it contains classes essential to the functioning of the JVM, for example, the class
Object
from which all other classes of the java itself or q vc create must inherit.– user28595
@Articunol actually as the inheritance is automatic would not need to import anyway
– Maniero
Without java.lang you couldn’t even do the method
main
, since its parameter is an array ofjava.lang.String
– hkotsubo