Computer Science, asked by Sachinsachii, 12 hours ago

Java program to print all substring of length 3 from a given string.​

Answers

Answered by nageshwarihatti51
0

Answer:

class SubstringsOfStringMain

{

public static void main(String args[])

{

String str="abc";

System.out.println("All substring of abbc are:");

for (int i = 0; i < str.length(); i++) {

for (int j = i+1; j <= str.length(); j++) {

System.out.println(str.substring(i,j));

}

}

}

}

Explanation:

output :

All substring of abc are:

a

ab

abc

b

bc

c

=> Solution is of o(n^3) time complexity.

Similar questions