Note: This solution is only for reference purpose. Feel free to use this solution as inspiration and enhance your knowledge but please don't literally copy and paste the code.
Solution of the problem:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | import java.util.Arrays; public class HowWillYouCompare { private static class Comparator { public boolean compare(int a, int b) { return a == b; } public boolean compare(String a, String b) { return a.equals(b); } public boolean compare(int[] a, int[] b) { return Arrays.equals(a, b); } } } |
Labels : #hackerrank certification ,#java (basic) ,