How to compare variable with multiple variable?
Hi!
Can you help me how to compare my choose variable with multiple variable?
which i can be used?
because i used == but not working..
this is my code
Code :
if(this.myPick == this.box1 && this.myPick == this.box2)
{
bet=bet*2;
money=money+bet;
System.out.println("You Got Double: " + bet);
}
else if(this.myPick == this.box2 && this.myPick == this.box3)
{
bet=bet*2;
money=money+bet;
System.out.println("You Got Double: " + bet);
}
else if(this.myPick == this.box3 && this.myPick == this.box1)
{
bet=bet*2;
money=money+bet;
System.out.println("You Got Double: " + bet);
}
else if(this.myPick == this.box1 && this.myPick == this.box2 && this.myPick == this.box3)
{
bet=bet*3;
money=money+bet;
System.out.println("You Got Triple: " + bet);
Re: How to compare variable with multiple variable?
The == operator is for comparing primitives. The equals() method is for comparing the contents of objects.
What is the code comparing? Primitives or object contents?
Re: How to compare variable with multiple variable?
thank for reply
ok, what should i use..how to use that equals()..?
Re: How to compare variable with multiple variable?
Use equals like any other method: var.equals(vsr2)
Also posted at http://www.java-forums.org/new-java/...-variable.html