aspose file tools*
The moose likes Beginning Java and the fly likes How Do I Type the Symbol for the Or Operator Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "How Do I Type the Symbol for the Or Operator" Watch "How Do I Type the Symbol for the Or Operator" New topic
Author

How Do I Type the Symbol for the Or Operator

Benjamin Chau
Ranch Hand

Joined: Oct 05, 2008
Posts: 49
Question: Can someone tell me how to type the symbol for the Or operator? Usually it's two vertical lines side by side (kinda like this: ll) but I don't know how to do that on the computer keyboard, unless I use the Shift, Alt, Function, and/or Ctrl keys, etc.

Can I just use the word "or" instead of the symbol ??? Also, is the Boolean symbol for Or the same as the arithmetic symbol for Or ???
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 40029
    
  28
Varies from country to country. On my keyboard it is at the bottom left, shift-\
Benjamin Chau
Ranch Hand

Joined: Oct 05, 2008
Posts: 49
TOO COOL! Thanks Campbell!
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 19059
    
  40

Also, is the Boolean symbol for Or the same as the arithmetic symbol for Or ???


No. The logical OR is a double vertical, while the arithmetic OR is a single vertical.

And BTW, on my keyboard, it is also "shift-backslash", but mine is located right above the return key.

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Benjamin Chau
Ranch Hand

Joined: Oct 05, 2008
Posts: 49
Henry,

Will you check my code in the other topic I submitted "Program: Change Due/Tendered"? I know what you said in response to it - I'm still working on compile issues. Specifically, will you check my code within the do...while statement to see if my use of the single vertical line | for the Or operator fits this situation? We just talked about that in this post thread and this part of the program in question deals with it. But I'm having trouble determining whether this case is logical or arithmetic (I'm leaning towards arithmetic, as reflected in my code). Thanks a bunch...

Benjamin
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

By the way, this character is often called a "pipe."


"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19781
    
  20

Originally posted by Henry Wong:
No. The logical OR is a double vertical, while the arithmetic OR is a single vertical.

Logical OR can be both | and || - the first one always evaluates the right operand, the second only if the first operand results in false.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
J. Noah
Greenhorn

Joined: Nov 15, 2008
Posts: 9
I actually don't think that's correct - one pipe is for bitwise inclusive OR. http://java.sun.com/docs/books/tutorial/java/nutsandbolts/operators.html


<a href="http://blog.expensivedna.com" target="_blank" rel="nofollow">http://blog.expensivedna.com</a>
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 40029
    
  28
You can use the | with booleans as an inclusive OR.
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 31054
    
162

Originally posted by Campbell Ritchie:
Varies from country to country. On my keyboard it is at the bottom left, shift-\

It also varies within a country. I'm in the United States and my work keyboard and home keyboard have the key in different places. Which is annoying because you have to remember where you are before touch typing!

General convention is either above/below/next to the "enter" key so at least there are only two places to look.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343


The tutorial seems a "bit" lacking in this respect.

For clarification, see JLS - 15.22.2 Boolean Logical Operators &, ^, and |...
When both operands of a &, ^, or | operator are of type boolean or Boolean, then the type of the bitwise operator expression is boolean.

As Rob pointed out, the difference is that the || is conditional, in that the right operand is evaluated only if the left operand evaluates to false. See JLS - 15.24 Conditional-Or Operator ||.

(In this context, it seems as if the tutorial might be treating a boolean as a single bit, which I think is a mistake, because the size of a Java boolean is not defined.)
[ November 16, 2008: Message edited by: marc weber ]
 
 
subject: How Do I Type the Symbol for the Or Operator