+ 2
In c, can i used equals() function to compare the two values of character variable? If yes, then how?
Suppose one program in which i accept value from user and stored it in variable 'a'. And i declare another variable named as 'b'and assign it a value as 5. so i want to compare the values of both a and b variable.
4 Antworten
+ 2
equals () is useful when comparing objects. And to compare numbers, you can use
if (==) {
}else{
}
+ 1
public static void main(String[] args) {
/**
consider comparing two identical
numbers created using the Integer class
**/
Integer a = new Integer(6);
Integer b = new Integer(6);
// false
System.out.println(a == b);
//true
System.out.println(a.equals(b));
}
+ 1
thanks 👍
0
can u give me the example of equals() function?