accepts two strings and returns the character index of the position
where the second string begins in the first; returns -1 if the second string does not appear in the first.
Examples:
IN: mississippi ss OUT: 2
IN: superlative zzl OUT: -1
Code java:public class Test { public static void main(String[] args) { String s1 = "mississippi"; String s2 = "s"; System.out.print(findInStr(s1, s2)); } public static int findInStr(String s1, String s2) { char c =(char) s2; if( s1.substring(1, s1.length()-1) == c ) { return s1.indexof(c); } else{ return -1; } } }
