subVirus? :D I merged your two topics and marked the original one as un-solved.
Oops, made a few logical errors in my solution a few posts back.
public static int substring(String str1,...
Type: Posts; User: helloworld922
subVirus? :D I merged your two topics and marked the original one as un-solved.
Oops, made a few logical errors in my solution a few posts back.
public static int substring(String str1,...
you're missing a closing parenthesis :)
str2.equals(str1.substring(i, str1.length()) + str1.substring(0, str2.length() - i)))
public static int substring(String str1, String str2)
{
for (int i = 0; i+str2.length() < str1.length(); i++)
{
if (str2.equals(str1.substring(i,i+str2.length()))
{...
You're return statements are pre-mature. The program hasn't completely checked that the string is contained str2 is a substring of str1, but you're saying it is. Also, return is a Java keyword. You...
Here's a simple algorithm to check if a substring is contained within another string:
1. start from the beginning of the larger string
2. If the remaining characters is greater than the length of...