java - How come this doesn't work [trying to print out a new sentence with all the constants] -
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(); (int = 0; >=len; i++) { if(vowels.indexof(sentance.touppercase().charat(i))>0) { newsentance+=sentance.charat(i); } } system.out.println(newsentance); } }
i getting no errors in netbeans yet still returns nil when printing newsentance .length working returns number correctly if printed
what else be?
modifying code
int = 0; < len; i++
and
vowels.indexof(sentance.touppercase().charat(i)) < 0
results in constants getting printed.
java string indexof
No comments:
Post a Comment