public class Recursion{
public static int first=-1;
public static int last=-1;
public static void Fibbo(String str,int idx, char element){
if(idx==str.length()){
System.out.println(first);
System.out.println(last);
return;
}
char currCharar=str.charAt(idx);
if(currCharar==element){
if(first==-1){
first=idx;
}
else{
last=idx;
}
}
Fibbo(str,idx+1,element);
}
public static void main(String args[]){
String str="abah";
Fibbo(str,0,'a');
}
}
0 Comments