Strings:

Any thing in double quotation " is called as string object in java. We can create strings in 2 ways
 main()
 {
   String str1="hi";
   String str2=new string("hi");
 }

Properties of strings:

-> Strings are immutable(unchangeable) objects. -> Sometimes strings will be stored in string constant pool and sometimes in the heap depending on the logic.

String constant pool:

->If we don't use "new" operator when creating string, it will be stored in string constant pool. ->But before storing it will check if that object is already available or not in that string constant pool. Note: -> If the string object is already available in the string constant pool, then it will not create a new object. -> If you create strings with "new" operator it will be stored in the heap. But before creating the string it will not check if that string is already available in heap or not. Stringpool
main()
{
   String str1=  "hi";
   String str2= new String("hi");
   String str3="hi";
   String str4= new String("hi");
}
new
In the above example we are trying to copy a string int str but strings are "immutable". So rather than modifying in same location it will create one more object in the string constant pool.

String functions:

Stringfunction We can append one more string to existing string using concat(). Stringfunction1

3. equals():

Check if two functions/strings are equal or not.

4. indexOf:

main()
{
  String str= "tech palle";
  str.indexOf('e');
}

5. subString:

main()
{
  String str="tech palle";
  String res = str.substring(2);
  System.out.println(res); // ouput: from 2 it  will start printing.
}
-> I want to create a string and share it will multiple threads where those threads must not be modified my string. -> Advantage of string is we can share it with multiple threads. App/Process Appprocess