this is my code, where i am just reversing the loop and then increasing the counter such that for the first occurrence the count value is 1 and hence skips the println() case. After this, in the second occurrence it will go to the nested if case and just print the index of the second last vowel.
class Main {
public static void main(String[] args) {
int count=0;
String str = "corresponding";
for(int i=str.length();i>=0;i--){
if(i=='a' || i=='e' ||i =='i'|| i=='o'|| i=='u'){
count +=1;
if(count==2)
System.out.println(i);
else
continue;
}
else
continue;
}
}
}
I am not able to print due to some minor logical error which i am not able to figure out. Can anyone help me here.