Java: Accept two string and test if the second string contains the first one
Test Substring in String
Write a Java program to accept two strings and test if the second string contains the first one.
Visual Presentation:

Sample Solution:
Java Code:
Sample Output:
Input first string: Once in a blue moon Input second string: See eye to eye If the second string contains the first one? false
Flowchart:

For more Practice: Solve these Related Problems:
- Write a Java program to count the occurrences of a given substring within another string.
- Write a Java program to perform a case-insensitive check to see if one string contains another.
- Write a Java program to find and print all starting indices of a substring within a string.
- Write a Java program to determine the longest common substring between two input strings.
Java Code Editor:
Contribute your code and comments through Disqus.
Previous: Write a Java program to find the length of the longest consecutive sequence of a given array of integers.
Next: Write a Java program to get the number of element in a given array of integers that are smaller than the integer of another given array of integers.
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics