Total members 11889 |It is currently Thu Mar 28, 2024 11:04 pm Login / Join Codemiles

Java

C/C++

PHP

C#

HTML

CSS

ASP

Javascript

JQuery

AJAX

XSD

Python

Matlab

R Scripts

Weka





Comparison Operators in Java :
In Java like other programming languages such as C++/C, PHP, and C# you can compare the variables such integers, floats, short, long and double. All the comparison operators are binary. Our main focus in this article is the comparison of primitives data-types. If you come from C++/C background the examples most probably you already knew the content of this article.


Larger than operator - Operator (>)


This operator returns true if the first operand is larger than the second operand, false otherwise.
java code
long x=543L;
long y=243L;
if(x > y)
{
// Do thing
}


true if x larger than y else false

Larger and equal operator- Operator (>=)


This operator returns true if the first operand is larger or equal to the second operand, false otherwise.
java code
short x=3;
short y=32;
if(x >=y )
{
// do something
}


true if x larger than y or equal y else false


Less than operator- Operator (<)



This operator returns true if first operand is less than the second operand,false otherwise.
java code
float x=5.3f;
float y=55.3f;

if(x<y)
{
// Do Something
}


true if x smaller than y else false

Less than or equal operator- Operator (<=)


This operator returns true if first operand is less than or equal to the second operand,false otherwise.
java code
int x=4;
int y=5;
if(x<=y)
{
// do something
}

true if x smaller than or equal y else false

Equal Operator- Operator (==)


Check if the value of two operands are equal.
java code
int x=65;
int y=543;
if(x==y)
{
// Equal
}

true if x equal y otherwise false

Not Operator- Operator (!=)


java code
int x=4;
int y=45;
if(x!=y)
{
// Not equal
}


true if x not equal y otherwise false



_________________
M. S. Rakha, Ph.D.
Queen's University
Canada


Author:
Mastermind
User avatar Posts: 2715
Have thanks: 74 time
Post new topic Reply to topic  [ 1 post ] 

  Related Posts  to : Comparison Operators in java
 Arithmetic data comparison and decompression java code     -  
 Bitwise operators in java     -  
 Arithmetic Operators in java     -  
 Comparison Pitfall     -  
 Arithmetic data comparison in C#     -  
 Free Quality Comparison Guide to VoIP     -  
 PHP operators     -  
 difference between the >> and >>> operators     -  
 using bit-wise operators in c++     -  
 Using Assignment Operators     -  



Topic Tags

Java Basics
cron





Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com