This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
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


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
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: 1087
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: 18756
    
  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: 1087
i do some changes in brackets.but hat is not effected final result.
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18756
    
  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: 11254
    
  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: 1087
thanks all.its fine now.I change the variable after the block completed.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: how to check primitive two integers are equal