हिंदी

Differentiate between compareTo() and equals(). - Computer Applications

Advertisements
Advertisements

प्रश्न

Differentiate between compareTo() and equals().

अंतर स्पष्ट करें

उत्तर

S. No. compareTo() equals()
1. This function analyses whether a string is equal to, more significant than, or smaller than another string. This function in the String class checks if two strings are identical. (The equals() function handles upper and lower case characters differently).
2. It produces an integer-type value. (The function returns 0 if both strings are equal, a negative number if the first string is smaller, and a positive value if the first string is larger). It returns a boolean value (true or false).
shaalaa.com
  क्या इस प्रश्न या उत्तर में कोई त्रुटि है?
अध्याय 4: String Handling - EXERCISES [पृष्ठ २८९]

APPEARS IN

अविचल Computer Applications [English] Class 10 ICSE
अध्याय 4 String Handling
EXERCISES | Q VI. 2. | पृष्ठ २८९
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×