76 285
Assignments Done
Successfully Done
In May 2019

Answer to Question #47371 in Java | JSP | JSF for neha reddy

Question #47371
Compare String values
Write a program that reads two strings from the keyboard and compares them and prints whether they are equal or not.
Expert's answer
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
String s1, s2;
System.out.print("Input first string: ");
s1 = in.next();
System.out.print("Input second string: ");
s2 = in.next();
if (s1.equals(s2)) {
System.out.println("The strings are equal");
} else {
System.out.println("The strings are not equal");

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!


No comments. Be first!

Leave a comment

Ask Your question

Privacy policy Terms and Conditions