Java String endsWith()

 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


Promote your Blog, Website, or services on technicalkeeda.com, My paypal id: yashwantchavan@gmail.com

Payment will be accepted through paypal only.


© technicalkeeda.com 2017

 |  Find us on Google+ |  Rss Feed

Loaded in 0.0293 seconds.