Java program problem in identifying longest match sub string between two string

Welcome to the Java Programming Forums

The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.

this now would return the length of the match in characters.. however if there were more matches..it will also include it....which is not i want. i just wanted the the longest match in charcters between the two string.

now to follow this...what it does is that it takes two strings.. the second string it breaks it up into all permutations and then compare it to the first. it would then suppose to return a list of all the matches it finds in both strings..
for example if the first string were hello and the second were mello.. this what the program will actually do.

please Enter the First String
hello
please Enter the Second String
mello
[mello, ello, llo, lo, o]
as you can see it gives me all the possible permutations of mello to campare to hello.
if i compare them now it suppose to return alist of all matches, example; ello would match, hence ello would be return.
this is actuall happen, but the problem now is that the program is appending the mathces and returning the result.
example;
please Enter the First String
hello
please Enter the Second String
mello
[, ello, ellollo, ellollolo, ellolloloo]
so u would see now that ello was matched, then llo but it was added on to ello first before returning.. this is where i got stuck..
i think the problem is with the LCM method.
that is