Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

find all possible substrings of a string java

for (int i = 0; i < A.length(); i++) {
    for (int j = i+1; j <= A.length(); j++) {
        System.out.println(A.substring(i,j));
    }
}
Comment

find all substrings of string in java

//Java program to print all possible
// substrings of a given string
 
class GFG {
 
// Function to print all sub strings
    static void subString(char str[], int n) {
        // Pick starting point
        for (int len = 1; len <= n; len++) {
            // Pick ending point
            for (int i = 0; i <= n - len; i++) {
                //  Print characters from current
                // starting point to current ending
                // point. 
                int j = i + len - 1;
                for (int k = i; k <= j; k++) {
                    System.out.print(str[k]);
                }
 
                System.out.println();
            }
        }
    }
 
// Driver program to test above function
    public static void main(String[] args) {
        char str[] = {'a', 'b', 'c'};
        subString(str, str.length);
 
    }
}
// This code is contributed by PrinciRaj1992
Comment

PREVIOUS NEXT
Code Example
Java :: default night mode not working 
Java :: appcompatdelegate.setdefaultnightmode(appcompatdelegate.mode_night_yes) not working 
Java :: java dictionary 
Java :: hql return new object from query 
Java :: java ee service formparam optional 
Java :: java popup message 
Java :: java 2d game tutorial 
Java :: java load file from resources 
Java :: .tar to .ova 
Java :: java convert double to string 
Java :: get height of a dialog fragment android 
Java :: How to find the power of a number efficiently in Java? 
Java :: spring jpa tree structure 
Java :: java take out cn from dn 
Java :: button background color not changing android 
Java :: java transform hashmap to list 
Java :: clear back stack android 
Java :: How to perform an iterative depth first search through a binary tree, in Java? 
Java :: why python is slower than java 
Java :: Authentication Server with spring, JWT & JPA 
Java :: a java exception is an instance of ? 
Java :: java check if directory exists 
Java :: how to get contacts permission in android 
Java :: onclick android 
Java :: how to delete files in java 
Java :: spigot remove every entity 
Java :: minecraft java 
Java :: why to use serializable with java bean 
Java :: java equals ignore case 
Java :: string replace last character java 
ADD CONTENT
Topic
Content
Source link
Name
4+6 =