The code is self-explanatory. It has \$O(n)\$ complexity, and it tells whether a given string is the substring of the source string. Are there any cases where this algorithm fails? Is there anything that can be improved?
public static boolean isSubStringOf(char src[], char target[]) {
int pointTarget=0;
for (int pointSrc = 0;pointSrc < src.length; pointSrc++) {
// If target's pointer is at target's length , Voila !
if (pointTarget == target.length)
return true;
//If value at src's pointer equals value at target's pointer increment target's pointer and continue.
if (src[pointSrc] == target[pointTarget]) {
pointTarget++;
continue;
}
//However if they are not equal reset target's pointer back to target's beginning.
else if (src[pointSrc] != target[pointTarget]) {
pointTarget = 0;
}
}
// To handle right corner case
return pointTarget == target.length;
}