What is string class in java?

Technology: java
AskedIn:
Topics:
Type:

String class in java is used to declare variable of type string (sequence of chars)

  • // for example String name = "Cortana";
  • Strings in java are not of primitive type but are objects of predefined class Stringm 
  • some methods of string class
    • length()
    • indexOf()
    • isEmpty()
    • charAt()
    • subString()
    • toString()
  • Java strings are immutable; it means once we create a string it cannot be changed
  • Java strings can also be created using new keyword
  • String name = new String("Cortana");