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

25th Mar 2018, 4:13 PM
varun pawar
4 Réponses
+ 2
equals () is useful when comparing objects. And to compare numbers, you can use if (==) { }else{ }
25th Mar 2018, 4:16 PM
Aidos Zhakupov
Aidos Zhakupov - avatar
+ 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)); }
26th Mar 2018, 1:13 PM
Aidos Zhakupov
Aidos Zhakupov - avatar
+ 1
thanks 👍
26th Mar 2018, 1:15 PM
varun pawar
0
can u give me the example of equals() function?
26th Mar 2018, 12:50 PM
varun pawar