Java String concat() method


In this program, You will learn how to implement the String concat() method in java.


if (a.concat(b)) { 
    //statement
}

Example: How to implement the String concat() method in java.

import java.util.Scanner;

class Main {
    public static void main(String args[]) {

        Scanner sc = new Scanner(System.in);
        String a, b;

        System.out.print("Enter first string:");
        a = sc.nextLine();

        System.out.print("Enter second string:");
        b = sc.nextLine();

        a = a.concat(b);
        System.out.print("After concat :" + a);

    }
}

Output:

Enter first string:Xiith
Enter second string:.com
After concat :Xiith.com

Xiith is created for educational, experimental, and schooling purpose. Examples on Xiith are made easier to make a better or basic understanding. Tutorials, testimonials, and examples are continuously checked to avoid delusion, but we cannot take complete responsibility of all programs on Xiith. When you are operating this site, you have to agree to read and accept our terms of use, cookie and privacy policy.Copyright © 2020 by Xiith. All Rights Reserved. About us.