Wht is the function can compare tow variable | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Wht is the function can compare tow variable

16th Mar 2017, 1:10 AM
Mr Sab
4 Answers
+ 11
compareTo() method is used  to compare two strings and it returns zero if two Strings are same, less than zero if calling string comes before argument string and greater than zero if calling string comes later than argumentstring as shown in example below.  String tv = "Bravia"; String television = "Bravia"; if (tv.compareTo(television) == 0) {             System.out.println("Both tv and television are equal using compareTo method of String");         }
16th Mar 2017, 2:24 AM
Mohammad Dakdouk
Mohammad Dakdouk - avatar
+ 1
in c++ u can use strcmp(...1...,...2); 2 cmpre 2 strings
22nd Mar 2017, 11:35 AM
Ajmal Aboobacker
Ajmal   Aboobacker - avatar
0
thx 4 info
22nd Mar 2017, 3:35 PM
Mr Sab
0
if int can use == ?
23rd Mar 2017, 2:32 PM
Mr Sab