Is string a primitive data type in Java ?

String is NOT a primitive data type in java. The only primitive data types are

  • int
  • short
  • long
  • double
  • float
  • byte
  • boolean
  • char

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.
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s