import java.util.Scanner;
public class JavaInhouseSubstring
{
public static void main(String args[])
{
String str, sub;
int i, c, length;
str = "substring";
length = str.length();
System.out.println("Substrings of \""+str+"\" are :-");
for( c = 0 ; c < length ; c++ )
{
for( i = 1 ; i <= length - c ; i++ )
{
sub = str.substring(c, c+i);
System.out.print(sub+" ");
}
}
}
}
|
subString present in a given string |
Post a Comment