← Back to list

1 . int compareTo() : Compares two strings lexicographically(Alphabetical order).

2. string compareToIgnoreCase() : Compares two strings lexicographically, ignoring case differences(independent of lower or upper case).

Kshitij Kumar · 2023-01-22 16:32 · 0 claps · 1.0 min read
#java #java-development #java12 #java-strings #java-string-methods
Open on Medium ↗
Wiki topics: GEN · Genomics & Sequencing

Find out at least 10 methods of a String?

1 . int compareTo() : Compares two strings lexicographically(Alphabetical order).

  1. string compareToIgnoreCase() : Compares two strings lexicographically, ignoring case differences(independent of lower or upper case).

  2. string concat() : Appends a string to the end of another string.

  3. boolean contains() : Checks whether a string contains a sequence of characters.

  4. boolean contentEquals() : Checks whether a string contains the exact same sequence of characters of the specified CharSequence or StringBuffer.

  5. string copyValueOf() : Returns a String that represents the characters of the character array.

  6. boolean equals() : Compares two strings. Returns true if the strings are equal, and false if not.

  7. boolean equalsIgnoreCase() : Compares two strings, ignoring case considerations.

  8. string format() : Returns a formatted string using the specified locale, format string, and arguments.

  9. void getChars() : Copies characters from a string to an array of chars.

  10. int indexOf() : Returns the position of the first found occurrence of specified characters in a string.

  11. string intern() : Returns the canonical representation for the string object.

  12. boolean isEmpty() : Checks whether a string is empty or not.

  13. string replace() : Searches a string for a specified value, and returns a new string where the specified values are replaced.

  14. string toLowerCase() : Converts a string to lower case letters.

  15. string toUpperCase() : Converts a string to upper case letters.

  16. string toString() : Returns the value of a String object.


메타데이터
post_id
3acb61fcd80c
slug
1-int-compareto-compares-two-strings-lexicographically-alphabetical-order-3acb61fcd80c
url
https://medium.com/@kshitijkumar021991/1-int-compareto-compares-two-strings-lexicographically-alphabetical-order-3acb61fcd80c
canonical_url
https://medium.com/@kshitijkumar021991/1-int-compareto-compares-two-strings-lexicographically-alphabetical-order-3acb61fcd80c
author_url
https://medium.com/@kshitijkumar021991
status
ok
fetched_at
2026-07-26 06:08:31