wood burning stoves 2.0*
The moose likes Java in General and the fly likes how to check primitive two integers are equal Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "how to check primitive two integers are equal" Watch "how to check primitive two integers are equal" New topic
Author

how to check primitive two integers are equal

sam liyanage
Ranch Hand

Joined: Nov 25, 2008
Posts: 1072
i have two integer primitive values.i need to check whether they are equal.if i use below i doesn't work
int a=5;
int b=5;
if(a==b){
}
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18532
    
  40

sam liyanage wrote:i have two integer primitive values.i need to check whether they are equal.if i use below i doesn't work
int a=5;
int b=5;
if(a==b){
}



What do you mean by "doesn't work"? Are you saying that the code in the conditional (assuming that you add some code) doesn't get called?

Henry
Raymond Tong
Ranch Hand

Joined: Aug 15, 2010
Posts: 230
    
    2

What do you mean by "doesn't work" ?
sam liyanage
Ranch Hand

Joined: Nov 25, 2008
Posts: 1072
i do some changes in brackets.but hat is not effected final result.
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18532
    
  40

sam liyanage wrote:i do some changes in brackets.but hat is not effected final result.



Perhaps it would be a good idea to provide a SSCCE that demonstrates the issue.

Henry
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11161
    
  16

sam liyanage wrote:i do some changes in brackets.but hat is not effected final result.

So how do you know it is the if-statement and the comparison, and not the code inside the block that is broken?
sam liyanage
Ranch Hand

Joined: Nov 25, 2008
Posts: 1072
thanks all.its fine now.I change the variable after the block completed.
 
jQuery in Action, 2nd edition
 
subject: how to check primitive two integers are equal
 
Similar Threads
Overloading Methods using Widening, Boxing, Var-args
Array Declaration
== is use for object Reference Equality so how can we use on primitive veriable
Integer Class
int VS Integer