ava Programming Problem: Write a generic isEqualTo that compares its two arguments/paramaters with the equals method and return true if the two are equals and false if not equal. Note: Please fix the code below where it will return true if the two are equals and false if not equal. import java.util.*; public class IsEqualTo { public static boolean isEqual(String str1, String str2){ return str1.equals(str2); } public static void main(String[] args) { Scanner scan = new Scanner(System.in); String str1 = scan.next(); String str2 = scan.next(); if(isEqual(str1, str2)){ System.out.println("String is equal"); } else { System.out.println("String is not equal"); } } }
Java
Problem: Write a generic isEqualTo that compares its two arguments/paramaters with the equals method and return true if the two are equals and false if not equal.
Note: Please fix the code below where it will return true if the two are equals and false if not equal.
import java.util.*;
public class IsEqualTo {
public static boolean isEqual(String str1, String str2){
return str1.equals(str2);
}
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
String str1 = scan.next();
String str2 = scan.next();
if(isEqual(str1, str2)){
System.out.println("String is equal");
}
else {
System.out.println("String is not equal");
}
}
}
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 3 images