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?

Recommended Answers

All 3 Replies

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.