Java Program to Combine Two Strings | abba Pattern String Problem

Published: 10 May 2026
on channel: India Free Internship
120
3

🚀 In this video, you will learn how to solve the String Concatenation Problem in Java.

We are given two strings a and b, and we need to return the result in the format:

abba

Example:

Hi + Bye = HiByeByeHi

This is a very easy and important Java String program for beginners.

💻 Java Code:

import java.io.*;
import java.util.*;

public class Solution {

public static void main(String[] args) {
Scanner s = new Scanner(System.in);

String str = s.nextLine();
String str2 = s.nextLine();

System.out.print(str.concat(str2));
System.out.print(str2.concat(str));
}
}

📥 Sample Input:

Hi
Bye

📤 Output:

HiByeByeHi

🔥 Topics Covered:

Java String Concatenation
concat() Method in Java
Java Basic Programs
String Interview Questions
Java Coding Practice

📚 Java Basic Programs Playlist:
Java Basic Programs Playlist

   / @indiafreeinternship  


Hashtags
#Java #JavaProgramming #Coding #StringPrograms #JavaTutorial #Programming #JavaForBeginners #ConcatMethod #JavaCoding #HackerRank


On this page of the site you can watch the video online Java Program to Combine Two Strings | abba Pattern String Problem with a duration of hours minute second in good quality, which was uploaded by the user India Free Internship 10 May 2026, share the link with friends and acquaintances, this video has already been watched 120 times on youtube and it was liked by 3 viewers. Enjoy your viewing!