Java endswith() method

    endsWith() method

    This method will allow you to check if the given string ends with the given suffix. The true value will be returned if the string will get ends with the given suffix else the false value will get returned.

    Method implementation-

    public boolean endsWith(String suffix) {  
    
          return startsWith(suffix, value.length - suffix.value.length);  
    
      }  

    Syntax-

    public boolean endsWith(String suffix)

    Example-

    public class Simple{  
    
    public static void main(String[] args) {      
    
           String s1="how are you man";  
           System.out.println(s1.endsWith("n"));  
           System.out.println(s1.endsWith("man"));  
        }
    } 

    Output-