PROBLEM STATEMENT:
Write a program in Java to accept 2 Strings from the user and perform String
manipulation operations on them such as Concatenation, Reversing, Comparing, Length
& Copy.
CODE:
import [Link].*;
public class StringMan
{
public static void main(String args[])
{
Scanner sc=new Scanner([Link]);
[Link]("Enter 2 strings:");
String s=[Link]();
String m=[Link]();
String con=[Link](m);
[Link]("Concatenation of the 2 strings is:"+con);
int l=[Link]();
int k=[Link]();
[Link]("Length of the string "+s+" is "+l);
[Link]("Length of the string "+m+" is "+k);
int z=[Link](m);
if(z==0)
{
[Link]("Both strings are equal");
}
else
{
[Link]("Both strings are unequal");
}
[Link]("");
[Link]("Reverse of the string "+s+" is: ");
for(int i=l-1;i>=0;i--)
{
[Link]([Link](i));
}
[Link]("");
[Link]("Reverse of the string "+m+" is: ");
for(int i=k-1;i>=0;i--)
{
[Link]([Link](i));
}
[Link]("");
String copy=[Link](0);
String popy=[Link](0);
[Link]("Copied String are: "+copy+" and "+popy);
}
}
OUTPUT: