I'm a newbie, and...cannot find the answer on the Web.

If you want to use the OR operator in Java, "||", how can you type it so the compiler will accept it?
The character "|" on the same key with the backslash ("\") looks like it should be the right thing, but I'm getting these errors at the command-line: "not a statement" and "; expected".

What character(s), on a standard keyboard, should I be using to represent OR?

6 Years
Discussion Span
Last Post by morrigan.c

I'm not kidding. I really am at the Java kindergarten level. My background is pseudocode, where you simply write "or". Any help much appreciated.


Are you saying that you are not able to output the pipe character (|) using your keyboard? If yes, then try holding down SHIFT key and then press the key which has | and \ shown. If no, then post the code with which you are getting errors. Using the logical OR operator is as simple as:

boolean someStatus = someBoolean || otherBoolean;

Yes, that's exactly what I wanted to know. That that was the correct key. I appreciate your example, and your taking time to answer.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.