String Question 20

Home / Java Practice Question / String Question 20

String Question 20


WAP to find the index of a specific character in a string....


Program : 


public class StringPractise {

public static int findIdxOfChar(String str , char ch){

for(int i=0;i<str.length();i++){
if(str.charAt(i)==ch){
return i;
}
}

return -1; // Dummy Return.....
}

}