How to check if a substring exist is another string from a specific index using regionMatches() in Java

1 Answer

0 votes
package javaapplication1;

public class JavaApplication1 {

    public static void main(String[] args) {

        try {

            String s = "programming";

            if (s.regionMatches(4, "ram", 0, 3)) 
                System.out.println("yes");
            else
                System.out.println("no");

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

/*
             
run:
       
yes
    
 */

 



answered Nov 24, 2016 by avibootz
...