Perform automated and live-interactive testing on 3000+ real desktop and mobile devices online.
A subset of a string is a character or a group of characters inside the string. An example of a subset of a string LTB would be L T, B, LT, TB, LTB.
Here is the Java program that finds all the sub-string of a given string.
import java.util.Scanner;
class SubStrings
{
public static void main(String args[])
{
String str, substr;
int i, j, len;a
Scanner sc = new Scanner(System.in);
System.out.println("Enter a String to get its Substrings");
str = in.nextLine();
len = str.length();
System.out.println("Substrings of ""+str+"" are:");
for (k = 0; k < len; k++)
{
for(i = 1; i <= len-k; i++)
{
substr = str.substring(k, k+i);
System.out.println(substr);
}
}
}
}
Test your websites, web-apps, or mobile apps seamlessly with LambdaTest.
Start Free TestingEarn resume-worthy Selenium certifications that help you land a top job.
Learn MoreTest orchestration and execution cloud of 3000+ browsers and OS
24/7 support
Enterprise grade security
Fastest test execution cloud