aspose file tools*
The moose likes Beginning Java and the fly likes operator || cannot be applied to... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "operator || cannot be applied to..." Watch "operator || cannot be applied to..." New topic
Author

operator || cannot be applied to...

James Dark
Greenhorn

Joined: Mar 06, 2004
Posts: 11
Hi. I wanted to know how to be able to place a statement that will check if either letters are equal to the letter stored in a[0]. I know I could break it up but would like to know how to do it in one line. Do you have to do ASCII keys or something?

//a[0] is a String array that contains either "C" or "c"
//e[0] is a String array that holds words
if (a[0] == ("C" || "c"))
e[0] = "Correct";

Any help is appreciated. Thanks.
Tim West
Ranch Hand

Joined: Mar 15, 2004
Posts: 539
|| can only operate on booleans: what you give it on either side must evaluate to a boolean. If 'a' is an array of Strings:



I guess you could use == instead of .equals() here, but it's still generally a Bad Thing with Strings.


--Tim
James Dark
Greenhorn

Joined: Mar 06, 2004
Posts: 11
Thanks again! You helped me save so many lines of code!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: operator || cannot be applied to...
 
Similar Threads
Why This Error??
sorting a array
stack
String split function and "||" String
String Array