2:29 am - Tuesday March 28, 2017

check suffix of the string boolean endswith(string suffix)

CANDID INDUSTRIAL TRAINING -- CHENNAI
Corporate Training for Experienced Candidate
Struts | Hibernate | Spring | Java / J2EE
SOAP | RestFull | Design Pattern | more...
Ph: +91 72000 69003
137b, 2nd st, shanthi nagar, Chrompet, Chennai -600044

                    This method returns true if the character sequence represented by the argument is a suffix of the character sequence represented by this object,false otherwise.

                    Note that the result will be true if the argument is the empty string or is equal to this String object as determined by the equals(Object) method.

Example Program

public class Model1
{

public static void main(String args[])

  {

     String s = new String("hello");

     boolean retVal;

     retVal = s.endsWith( "hello" );

     System.out.println( retVal );

     retVal = s.endsWith( "hi" );

     System.out.println( retVal );

    }

}

Output

     true

     false

Filed in: Java Examples

Comments are closed.