I am working on a method for a project(one that translates into pig latin) that finds the first vowel in a word string. I have started the method, and am just experimenting with the vowel 'a' to keep it simple. It finds the position in the string and assigns that value to an int variable called vowelPosition. this is set to negative one, so if the word doesnt have any vowels it should stay as negative one, HOWEVER when i used "bat" and "apple" it stayed as negative one. It should have returned 1 and zero respectively. Here is my coding, hopefully someone can shead some light on my error.
public static int findFirstVowelPosition(String word) { int vowelPosition = -1; word = word.trim();
public class Test { public static void main(String args[]) { int vowelPosition = -1; String word = args[0]; word = word.trim(); String word1 = word; for(int i=0; i<word.length(); i++) { if(word1.substring(i,i+1).equalsIgnoreCase("a")) { vowelPosition = i; break; } word = word1;