Hi everybody,
i should write a methode, which gives the first occurence of a substring in a string with an index.
If the string starts with the substring so the index must be 0, if the substring does not exist in the string so the index is -1. If the substring.length is 0 so the index is 0.
The method is:
|
Code:
|
public static int getFirstOccurence(char[] str, char[] substr){
//TO DO
} |
The strings are changed into the array. In this method we are working with arrays which have charakters. (I've already wrote the methode to change strings into the array...)
Can anybody help me? I don't know how to search an array, in an other array?