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...



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");
        }
    }

}



Jun 08, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here