I was looking for questions that might be asked in a technical interview and I found this one:Write a function that determines if two integers are equal without using any comparative operators.I'm using Java and my solution was to wrap the ints in an Integer object, convert that Integer to a string and return:(firstInt.toString()).equals(secondInt.toString()).I have 2 questions:Is there a better Java answer to this question? Does this response fulfill the requirements and if so, is it a good one?public class Main{    public static void main(String[] args){        log(equal(1,2)); //prints out false        log(equal(67,67)); //print out true        log(equal(-5,-5)); //prints out true        log(equal(-9,-4)); //prints out false;    }    public static boolean equal(int a, int b){        Integer first = a;        Integer sec = b;        return (first.toString()).equals(sec.toString());    }    public static void log(Object o){        System.out.println(o);    }  }
Comparing 2 ints without using comparative operators
java;interview questions
I find it highly unlikely that the interview question is designed to be answered in Java. It is more than likely referring to languages that can evaluate non-boolean value types as boolean expressions. A possible solution in JavaScript could be:function equal(a, b) {    return !(a - b); // returns true only if (a - b) === 0}Is there a better Java answer to this question?You can simplify your method by calling toString on the Integer class and passing in the integer you wish to convert.public static boolean equal(int a, int b){    return Integer.toString(a).equals(Integer.toString(b));}Not that this is a better solution: a == b would be favored in any scenario.Does this response fulfill the requirements and if so, is it a good one?String.equals is doing a series of comparisons to verify the sequence of characters in your converted integers match; arguably this does not fulfill the requirements, but simply obfuscates it through an internal method call.