The concat method is used to merge two or more strings.

    
    String firstName = "John ";
    String lastName = "Doe";

    String nameConcat = firstName.concat(lastName);

    System.out.println(nameConcat);
    // "John Doe"