# String in-built basic and important functions to remember .

1. **charAt(int index):** Returns the character at the specified index.
    
    ```plaintext
    javaCopy codechar charAtIndex = myString.charAt(3);
    ```
    
2. **length():** Returns the length of the string.
    
    ```plaintext
    javaCopy codeint strLength = myString.length();
    ```
    
3. **substring(int beginIndex):** Returns a substring starting from the specified index.
    
    ```plaintext
    javaCopy codeString subString = myString.substring(2);
    ```
    
4. **substring(int beginIndex, int endIndex):** Returns a substring within the specified range.
    
    ```plaintext
    javaCopy codeString subString = myString.substring(2, 5);
    ```
    
5. **toLowerCase():** Converts all characters in the string to lowercase.
    
    ```plaintext
    javaCopy codeString lowerCaseString = myString.toLowerCase();
    ```
    
6. **toUpperCase():** Converts all characters in the string to uppercase.
    
    ```plaintext
    javaCopy codeString upperCaseString = myString.toUpperCase();
    ```
    
7. **trim():** Removes leading and trailing whitespaces from the string.
    
    ```plaintext
    javaCopy codeString trimmedString = myString.trim();
    ```
    
8. **equals(Object another):** Compares the content of two strings for equality.
    
    ```plaintext
    javaCopy codeboolean isEqual = myString.equals(anotherString);
    ```
    
9. **equalsIgnoreCase(String another):** Compares two strings for equality, ignoring case differences.
    
    ```plaintext
    javaCopy codeboolean isEqualIgnoreCase = myString.equalsIgnoreCase(anotherString);
    ```
    
10. **startsWith(String prefix):** Checks if the string starts with the specified prefix.
    
    ```plaintext
    javaCopy codeboolean startsWithPrefix = myString.startsWith("abc");
    ```
    
11. **endsWith(String suffix):** Checks if the string ends with the specified suffix.
    
    ```plaintext
    javaCopy codeboolean endsWithSuffix = myString.endsWith("xyz");
    ```
    
12. **indexOf(int ch):** Returns the index of the first occurrence of the specified character.
    
    ```plaintext
    javaCopy codeint indexOfChar = myString.indexOf('a');
    ```
    
13. **lastIndexOf(int ch):** Returns the index of the last occurrence of the specified character.
    
    ```plaintext
    javaCopy codeint lastIndexOfChar = myString.lastIndexOf('a');
    ```
    
14. **contains(CharSequence sequence):** Checks if the string contains the specified sequence of characters.
    
    ```plaintext
    javaCopy codeboolean containsSequence = myString.contains("abc");
    ```
    
15. **replace(char oldChar, char newChar):** Replaces all occurrences of a specified character with another character.
    
    ```plaintext
    javaCopy codeString replacedString = myString.replace('a', 'b');
    ```
