How to check if a string end with specified substring in Java

1 Answer

0 votes
package javaapplication1;

public class JavaApplication1 {

    public static void main(String[] args) {

        try {

            String s =  "java c c++";

            if (s.endsWith("c++")) 
                System.out.println("yes");
            else
                System.out.println("no");

        } catch (Exception e) {
            System.out.print(e.toString());
        }
    }
}

/*
           
run:
     
yes
  
 */

 



answered Nov 22, 2016 by avibootz

Related questions

...