top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration Why to Join

Facebook Login
Site Registration

Write a program which accepts 2 strings from the user and performs the following operation on it?

+1 vote
156 views

Write a program which accepts 2 strings from the user and performs the following operation on it.
Example –
string1 = “Hello”
string2 = “World”
string3 must be “HellodlroW”

Both strings must be concatenated but after reversing the second string (as shown in string3 above).

posted May 14, 2017 by Azhar Keer

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

+1 vote

public class StringConcatTest {

/**
 * @param args
 */
public static void main(String[] args) {

    Scanner sc=new Scanner(System.in);
    System.out.println("Enter two Strings");
    String s1=sc.nextLine();
    String s2=sc.nextLine();

    String s3=new StringBuilder(s1).append(new StringBuilder(s2).reverse()).toString();
    System.out.println(s3);

}

}

answer May 25, 2017 by S Santhosh
i need c code for this program
Similar Questions
+2 votes

Input:
arr = {'a', 'b'}, length = 3

Output:
aaa
aab
aba
abb
baa
bab
bba
bbb

+2 votes

Given 2 strings, a and b, return a string of the form shorterString+longerString+shorterString, with the shorter string on the outside and the longer string on the inside. The strings will not be the same length, but they may be empty (length 0). If input is "hi" and "hello", then output will be "hihellohi".

Contact Us
+91 9880187415
sales@queryhome.net
support@queryhome.net
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Bangalore-560102
Karnataka INDIA.
QUERY HOME
...