- Trending Categories
- Data Structure
- Operating System
- MS Excel
- C Programming
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Differences between & and && operators in Java.
& is a bitwise operator and compares each operand bitwise.
It is a binary AND Operator and copies a bit to the result if it exists in both operands.
Assume integer variable A holds 60 and variable B holds 13 then
(A & B) will give 12 which is 0000 1100.
Whereas && is a logical AND operator and operates on boolean operands. If both the operands are true, then the condition becomes true otherwise it is false. Assume boolean variable A holds true and variable B holds false then (A && B) is false.
& is to be used during bitwise operations and && is useful during logical operations.
- Related Articles
- Differences between | and || operators in Java
- What are the differences between bitwise and logical AND operators in C/C++
- What is the difference between >> and >>> operators in Java?
- Differences between HashMap and Hashtable in Java
- Differences between Collection and Collections in Java?
- Differences between Interface and class in Java
- Differences between ArrayList and LinkedList in Java
- Differences between Java 8 and Java 9?
- Major differences between C# and Java
- Differences between TreeMap, HashMap and LinkedHashMap in Java
- Differences between org.simple.json and org.json libraries in Java?
- Differences between wait() and sleep() method in Java?
- Differences between wait() and join() methods in Java
- Differences between Lambda Expressions and Closures in Java?
- Differences between abstract class and interface in Java