CharactersTopMiscellaneous interesting String methods:

Miscellaneous interesting String methods:

    public boolean startsWith(String s)
          // true only if this string starts with s
          
    public boolean endsWith(String s)
          // true only if this string ends with s

    public boolean equals(String s)
          // true only if this string has same sequence of chars as s
          
    public boolean equalsIgnoreCase(String s)
          // true only if this string has same sequence of chars as s
          // except capital & lower case letters considered the same

    public int lastIndexOf(String s)
    public int lastIndexOf(String s, int startIndex)
          // return index of last occurrence of s (occurring at or  
          // before startIndex) in this string, and -1 if no match.

    public String replace(char oldChar, char newChar)
          // Returns a new string resulting from replacing all  
          // occurrences of oldChar in this string with newChar. 
    
    public String trim()
          // Eliminates all leading and trailing spaces.
            
    public int compareTo(String s)
          // Returns negative int if string before s in case-sensitive
          //    dictionary order;
          // returns 0 if equal
          // returns positive int if string after s in case-sensitive
          //        dictionary order.

    public char charAt(int index)
            // Returns the character at the specified index. 

CharactersTopMiscellaneous interesting String methods: