String is NOT a primitive data type in java. The only primitive data types are
String just happens to be the most used object. it is available in the java.lang package; If it happens to be in a package, how come we can use it without importing ? java.lang.* is a special package that is imported by default in all java programs.
java.lang provides very important classes without which even your basic java program doesn’t run. It contains the major classes like
- primitive Wrapper classes like Double, Float
- Support classes for threads like Runnable
- Common Exception Classes
- Common Error Classes
- and of course the most important – Object Class (java.lang.object) in java which is the root of the Class hierarchy.