Continuous Test Orchestration And Execution Platform Online

Perform automated and live-interactive testing on 3000+ real desktop and mobile devices online.

Write a Java program to find all the sub-string of given string?

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.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);

Test your websites, web-apps, or mobile apps seamlessly with LambdaTest.

Start Free Testing

Earn resume-worthy Selenium certifications that help you land a top job.

Learn More

Test your web or mobile apps

Test orchestration and execution cloud of 3000+ browsers and OS


24/7 support


Enterprise grade security


Fastest test execution cloud