Im trying to reverse only the vowels of a string but it's just not happening. :-( Can anyone tell why is it so.
public class Program { public static boolean isVowel(String a) { String [] vowels = {"a","e","i","o","u"}; int j=0; int len = vowels.length; for(int i=0;i<len;i++) { if(a==vowels[i]) { j++; //break; } } if(j>0) return true; else return false; } public static void main(String[] args) { int z=0; String temp; String sent = "hellokitty"; String [] arr = sent.split(""); int len1 = arr.length-1; int las = len1; for(int k=0;k<len1/2;k++) { for(int i=z;i<=len1;i++) { if(isVowel(arr[i])==true) { z=i+1;; break; } } for(int j=las;j>=0;j--) { if(isVowel(arr[j])==true) { las=j-1;; break; } } temp = arr[z]; arr[z]=arr[las]; arr[las]=temp; } for(int l=0;l<=len1;l++) { System.out.print(arr[l]); } } }