File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

java awt if statement not working properly

 
Vaibhav Kaushal
Greenhorn
Posts: 5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
it is a program to find vowels from tect in awt....but it is not doing so may be some problem in if statement


 
Ulf Dittmer
Rancher
Pie
Posts: 42966
73
  • 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Strings are not compared using the "==" operator, but using the "equals" method.

Start by rewriting your code to use

char vowels[]={'a','e','i','o','u'}

instead of

String vowels[]={"a","e","i","o","u"}

If you do that, note that char is compared using "==", unlike String.

Once you got all this working, ask yourself whether é is a vowel for your purposes :-)
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic