Check out example codes for "string contains java". It will help you in understanding the concepts better.

Code Example 1

// Java code to demonstrate case 
// sensitivity of contains() method 
class Gfg1 { 
  
    // Driver code 
    public static void main(String args[]) 
    { 
        String s1 = "Welcome! to GFG"; 
  
        // prints false 
        System.out.println(s1.contains("Gfg")); 
  
        // prints true 
        System.out.println(s1.contains("GFG")); 
    } 
}

Code Example 2

String s1 = "My name is GFG"; 
  
// prints true 
System.out.println(s1.contains("GFG")); 
  
// prints false 
System.out.println(s1.contains("geeks"));

Code Example 3

class Test { 
    public static void main(String args[]) { 
        String s1 = "My name is X"; 
        System.out.println(s1.contains("X")); // prints true 
        System.out.println(s1.contains("Y")); // prints false 
    } 
}

Learn ReactJs, React Native from akashmittal.com