I have the following code :
public class Application {
public static void main(String[] args)
{
String source = "Testing";
go(source);
}
public static void go(String source)
{
for (int i = 0; i < source.length(); i ++)
{
for (int j = i + 1; j <= source.length(); j++)
{
System.out.println(source.substring(i, j));
}
}
}
}
When I run this code, I get the following output :
T
Te
Tes
Test
Testi
Testin
Testing
e
es
est
esti
estin
esting
s
st
sti
stin
sting
t
ti
tin
ting
i
in
ing
n
ng
g
Which is great and all - But it isn't actually what I want. I would also like to be able to get all the possible strings that are substrings of this word.
Such as gist, set, tie etc.
I realise how my code is wrong for this, but I am also unsure of how I might expand it out to achieve what I want!
Any help is appreciated!