Java program to find all substrings of String

In this post, we are going to see how to find substrings of String in java.

Problem: Find all substrings of given String

Example:

Input: “Code”

Output:

“C”
“Co”
“Cod”
“Code”
“o”
“od”
“ode”
“d”
“de”
“e”

We can use String’s subString method to do it.
We will two loops to achieve all SubStrings of String in java.

Output:

C
Co
Cod
Code
o
od
ode
d
de
e

Leave a Reply

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