Why is Java “String” type written in capital letter while “int” is not?

Because int is a primitive type, not a class, thus it is not directly comparable to String. The corresponding class type is Integer, spelled according to the class naming conventions.

Similar pairs of primitive and class types are

  • byte vs Byte
  • short vs Short
  • long vs Long
  • float vs Float
  • double vs Double
  • boolean vs Boolean
  • char vs Character

Leave a Comment

tech