Check out example codes for "how to append to a string in java". It will help you in understanding the concepts better.

Code Example 1

public class Concat {
    String cat(String a, String b) {
        a += b;
        return a;
    }
}

Code Example 2

// Java program to illustrate the 
// StringBuilder append(boolean a) 
import java.lang.*; 
  
public class Geeks { 
  
    public static void main(String[] args) 
    { 
  
        StringBuilder sb1 = new 
                      StringBuilder("Welcome to Geeksforgeeks "); 
        System.out.println("Input: " + sb1); 
  
        // Appending the boolean value 
        sb1.append(true); 
        System.out.println("Output: " + sb1); 
  
        System.out.println(); 
  
        StringBuilder sb2 = new StringBuilder("We fail- "); 
        System.out.println("Input: " + sb2); 
  
        // Appending the boolean value 
        sb2.append(false); 
        System.out.println("Output: " + sb2); 
    } 
}

Code Example 3

class Main
{
	public static void main(String args[])
    {
		String myString = "";
      	for (int i = 0; i < 3; i++)
        {
        	myString += "Hello There "; 
        }
      	System.out.println(myString); // Hello There Hello There Hello There 
    }
}

Learn ReactJs, React Native from akashmittal.com