File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes & operator Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "& operator" Watch "& operator" New topic

& operator

Shiva Mohan
Ranch Hand

Joined: Jan 05, 2006
Posts: 481
System.out.println("---->"+(-7&7)); prints 1
System.out.println(-2&-3); prints -4

but in the bit representation how to get the answer like this.
could anyone please explain in bit representation
marc weber

Joined: Aug 31, 2004
Posts: 11343

Applied to integral values, the & operator means "bitwise and." For each bit position, it returns 1 if the bits in that position of both operands are 1.

"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
I agree. Here's the link:
subject: & operator
It's not a secret anymore!