concatenation in java

Checking String concatenation



Steps to do it:-
1. take s1,s2,s3 3 String variables
2.take a scanner class and name the object as "s"

2. take two word from user and scan it by
s1=s.nextLine();

s2=s.nextLine();

3. now just add to string and store it in s3
s3=s1+s2;

in this process the concatenation will be done

4. print s3 
5.save and run

The Source Code

  import java.util.Scanner;
class stringcon
{
      public static void main(String[] args) {
        Scanner s=new Scanner(System.in);
        String s1,s2,s3;

        System.out.println("enter the 1st word");
        s1=s.nextLine();

        System.out.println("enter the 2nd word");
        s2=s.nextLine();

        s3=s1+s2;

        System.out.println("the concatenation is : "+s3);

    }
}
                                         OUTPUT



Watch My Video




Comments

Popular Posts