1. Home
  2. Computing & Technology
  3. Java

Equality Operator

By , About.com Guide

Definition:

There are two equality operators used to determine whether equality or inequality exists between two operands:

==    is equal to.
!=    is not equal to.

Both operators return a boolean value; true if the result of the equality operation is correct, otherwise false.

Examples:
int value = 10;

//does the value variable equal ten?
boolean isEqual = value == 10;

//does the value variable not equal ten?
boolean isNotEqual = value != 20;

//Normally they are used as part of a control flow statement
if (value == 10)
{
  System.out.println("Yay, the value is 10");
}

Glossary:

# A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

Explore Java
About.com Special Features

Holiday Central

What to eat, where to go, fun things to do and how to save money on the perfect gifts. More >

Family Tech Center

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

  1. Home
  2. Computing & Technology
  3. Java

©2009 About.com, a part of The New York Times Company.

All rights reserved.