Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

java awt if statement not working properly

 
Vaibhav Kaushal
Greenhorn
Posts: 5
  • 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
Posts: 42967
73
  • Likes 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