Java String endsWith() Method

 Posted On  | Yashwant Chavan 

In this tutorial you will learn how to use String.endsWith(String suffix) method. Tests if this string ends with the specified suffix value. It returns true if string ends with specified suffix, otherwise returns false value.

Refer below steps

  • boolean java.lang.String.endsWith(String suffix) method tests if this string ends with the specified suffix.
  • Returns true if string ends with specified suffix, false otherwise

Java String.endsWith(String suffix) method example

package com.technicalkeeda.app;

public class StringEndsWith {

    public static void main(String args[]) {
 
 String str = "technicalkeeda";
 System.out.println("endsWith keeda ? "  + str.endsWith("keeda"));
 System.out.println("endsWith Keeda ? "  + str.endsWith("Keeda"));
 System.out.println("endsWith hello ? "  + str.endsWith("hello"));
 System.out.println("endsWith technicalkeeda ? "  + str.endsWith("technicalkeeda"));
 
    }
}

Output

endsWith keeda ? true
endsWith Keeda ? false
endsWith hello ? false
endsWith technicalkeeda ? true


© technicalkeeda.com 2017

 |  Find us on Google+ |  Rss Feed

Loaded in 0.0233 seconds.