String str="1234";
String str2="1234";
BigInteger bigInt=new BigInteger("1234");
Object v1=str;
Object v2=str2;
Object v3=bigInt;
System.out.println("Condition1==>>"+v1.equals(v2));
System.out.println("Condition2==>>"+v1.equals(v3));`
Output:
Condition1==>>true
Condition2==>>false
Why the second condition( v1.equals(v3) ) result is false even though the values are same?.What is the difference between two conditions? How to make the second condition result to true?
String.equals(BigInteger)to ever returntrue? Those are 2 different types.for any non-null reference values x and y, this method returns true if and only if x and y refer to the same object (x == y has the value true).