Skip to content

How to Check if String contains Substring in Java

How do I check If a String contains another substring in Java? . This tutorial will help you to check if the main string contains another substring

Category
Programming
Covers
Java
Versions & support
About Java →
On this page

Question – How do I check If a String contains another substring in Java? In our previous article, you learned to compare two strings in Java programming language. This tutorial will help you to check if the main string contains another substring in it.

Syntax

Example 1 – Check with Case Sensitive

This will be case sensitive check. As per the below example, Welcome is different than welcome as we know java is a case sensitive programming language.

Example 2 – Check with Ignoring Case

Using this string will be checked with ignoring the case. The function change string to lower case and check if one string contains another case.

Rahul

Rahul Kumar is the founder and chief editor of TecAdmin.net. A Red Hat Certified Engineer (RHCE), he has worked in IT since 2009, with hands-on experience in Linux system administration, DevOps, web hosting, cloud platforms and automation. He started TecAdmin in 2013 to share practical, step-by-step guides, and leads its editorial work with one aim: making technical learning clear and useful for sysadmins, developers and beginners alike.

Leave a Reply

Your email address will not be published. Required fields are marked *


Back to top