Java Strings

Posted in Java Strings By Raj On December 16, 2017


The Java string is an array of zero or more Unicode characters which are stored in the heap memory, the string is an immutable, once, you assign a value to the string variable then you cannot change it, you can create a string object using below mentioned ways

  • Using String literal
  • Using new keyword

The example for string literal is assigning series of characters which are in the double quotes to the variable 

You can create a string object using new keyword something like below, but this creates a new object in the heap memory instead of checking in the string constant pool

String’s are immutable once you create it in the memory you can not change it, instead of that it will create a new string