Java 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"); } }}
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here