-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstring4.java
More file actions
29 lines (26 loc) · 781 Bytes
/
string4.java
File metadata and controls
29 lines (26 loc) · 781 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import java.util.Scanner;
public class string4 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("Input first string: ");
String str1 = sc.nextLine();
System.out.println("Input second string: ");
String str2 = sc.nextLine();
if(str1.length()>str2.length())
{
str1 = str1.substring(str1.length() - 2);
str1 = str1.concat(str2);
System.out.println("Output: "+str1);
}
else if(str2.length()>str1.length())
{
str2 = str2.substring(str2.length() - 2);
str1 = str1.concat(str2);
System.out.println("Output: "+str1);
}
else {
str1 = str1.concat(str2);
System.out.println("Output: "+str1);
}
}
}