Next-Gen App & Browser
Testing Cloud

Trusted by 2 Mn+ QAs & Devs to accelerate their release cycles

Next-Gen App & Browser Testing Cloud

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.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 Website on 3000+ Browsers

Get 100 minutes of automation test minutes FREE!!

Test Now...

KaneAI - Testing Assistant

World’s first AI-Native E2E testing agent.

...
ShadowLT Logo

Start your journey with LambdaTest

Get 100 minutes of automation test minutes FREE!!

Signup for free