Why doesn't Java need to import classes like Integer, String, etc. while it needs to import other classes?
相关问题
- Delete Messages from a Topic in Apache Kafka
- Jackson Deserialization not calling deserialize on
- How to maintain order of key-value in DataFrame sa
- StackExchange API - Deserialize Date in JSON Respo
- Difference between Types.INTEGER and Types.NULL in
Classes in the
java.lang
package do not need to be imported (the compiler acts like they are always imported). This package includes core classes such as String, Enum, Runnable, NullPointerException, and of course, the primitive wrapper classes such as Integer and Double.Integer,String etc classes are present in package java.lang which is default imported.
java.lang is in-build, implicitly imported in java, does'nt need to be manually imported
java.lang
package is imported by default, no need to explicitly import it.Because, they belongs to
java.lang.*
package. And, it is implicitly import by the compiler. If you do, then it won't complain you.As it contains very frequently used classes, they have made it optional to import just for your convenience