Java Program to Append(Concatenate) one string to another string

By | 09.02.2017

Java Program to Append(Concatenate) one string to another


Java Program to  concatenate or to append one string to another string in Java Programming, you have to ask to the user to enter the two string and start concatenating one string into the other using the concat() function.

In this program ,we are going to use in-built functions for appending one string to another.Below is the source code of the program u want……


SOURCE CODE ::

 

import java.util.Scanner;

public class Append_string
{
   public static void main(String args[])
   {
      String str1, str2;
      Scanner scan = new Scanner(System.in);
 
      System.out.print("Enter First String : ");
      str1 = scan.nextLine();
      System.out.print("Enter Second String : ");
      str2 = scan.nextLine();
      
      System.out.print("Concatenating String 2 into String 1...\n");
      str1 = str1.concat(str2);
          
      System.out.print("String 1 after Concatenation is " +str1);
   }
}

 

OUTPUT ::

 

Enter First String : Codez
Enter Second String : Club
Concatenating String 2 into String 1...
String 1 after Concatenation is CodezClub

 

0 0 votes
Article Rating
Category: Java Programming String Programs Tags:

About Tunde A

My name is Tunde Ajetomobi, a Tech Enthusiast and Growth Hacker. I enjoy creating helpful content that solves problem across different topics. Codezclub is my way of helping young aspiring programmers and students to hone their skills and find solutions on fundamental programming languages.

Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments