Answer:
import java.util.Scanner;
public class Main {
public static void main(String[] args) throws Exception {
Scanner myObj = new Scanner(System.in);
//Request and receive first String
System.out.println("Enter username");
String firstString = myObj.nextLine();
//Request and receive second string
System.out.println("Enter second string");
String secondString = myObj.nextLine();
//Request and receive third string
System.out.println("Enter third string");
String thirdString = myObj.nextLine();
//Concatenate the first and second string
String concatA_B = firstString + secondString;
if(concatA_B.equals(thirdString)){
System.out.println("First String Concatenated to Second String is equals to the third String");
}
else{
System.out.println("First String Concatenated to Second String is NOT equals to the third String");
}
}
}
Explanation:
- Import Scanner Class
- Request and Receive three variables from the user using the Scanner Class
- Concatenate the first and second
- Use the .equals() method to check for equality