import javax.swing.JOptionPane;
public class Indexof {
public static void main(String[] args) {
String newSentance = "";
String sentance = JOptionPane.showInputDialog("Enter sentance");
String vowels = "AEIOU";
int len = sentance.length();
for (int i = 0; i >=len; i++)
{
if(vowels.indexOf(sentance.toUpperCase().charAt(i))>0)
{
newSentance+=sentance.charAt(i);
}
}
System.out.println(newSentance);
}
}
I am getting no errors in NetBeans yet it still returns nothing when printing newSentance
the .length is definitely working as it returns the number correctly if printed
what else could it be?
Modifying the code with
and
results in only the constants getting printed.