

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


Java Program Output
Java Program Output
public class Example { public static void main(String[] args) { String str1 = "apple"; String str2 = "pp"; boolean result = str1.contains(str2); System.out.println("Does str1 contains str2? " + result); } } Does str1 contains str2? true public class Example { public static void main(String[] args) { String str1 = "apple"; String str2 = "kk"; boolean result = str1.contains(str2); System.out.println("Does str1 contains str2? " + result); } } Does str1 contains str2? false
Conclusion In this Java Tutorial, we learned how to check if a string contains another string in Java. ✦ Java Tutorial Java String Operations ✦ Java String ✦ Java String Operations ✦ Java - Print String to Console ✦ Java - Read String from Console ✦ Java - Concatente two Strings ✦ Java - Check if Strings are Equal ✦ Java - Find Index of First Occurrence of Substring ✦ Java - Find Index of Nth Occurrence of Substring ✦ Java - Replace First Occurrence of Substring ✦ Java - Replace All Occurrences of Substring ✦ Java - Reverse a String ✦ Java - Split String ✦ Java - Trim String