Compare 2 Strings
I know how to compare 2 Strings, but I want to write out to the console parts of Strings that are same for both. Example: String text1 = "random"; String text2 = "tworanthing"; So here "ran" is same for both Strings. I want to know how to output it.
A way is to use two loops, an outer loop and inner loop. The outer loop loops through all possible substrings of the first string and the inner will loop through all substrings of the second string(with length equal to the length of the current substring of the first string) to find all possible "equal" substrings
What attempt have you made to do this?
@RandomCoder if you need further help, drop a comment on my code as I may miss a notification from here
Thanks, I got it. I will give it a try :)
I did not make it out because I don't know how to do it :P I tried to compare two Strings but it returns true or false so it is useless. I want to write same parts of those strings and not just return true of false
String text1 = "aabbccdd"; String text2 = "eehhkkcc"; So same here is "cc" and I want to write it