Advertisement

02.20.2005 at 11:22PM PST, ID: 21322370
[x]
Attachment Details

Evaluating char data.

Asked by jazduck in Java Programming Language

Whats the best way to acheive something like: if (nChar == 'a' || 'e' || 'i' || 'o' || 'u')
That throws an error as || cant be used with boolean or char types. However, shouldnt 'a' give you the integer value of a ?

So if i do:  int nChar = text.charAt(i); if (nChar == 'a' || 'e' || 'i' || 'o' || 'u') {}  i should be evaluating two integers, yet it still doesnt work.

The other options i can think of are nested if statements *yuck* or to use switch, but im more interested why the simple if or statement wont work.

Jaz
 Start Free Trial
 
 
[+][-]02.20.2005 at 11:25PM PST, ID: 13360681

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Java Programming Language
Sign Up Now!
Solution Provided By: objects
Participating Experts: 1
Solution Grade: A
 
 
[+][-]02.20.2005 at 11:26PM PST, ID: 13360682

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02.20.2005 at 11:47PM PST, ID: 13360755

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]02.21.2005 at 12:23AM PST, ID: 13360870

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32