Results 1 to 6 of 6
- 09-11-2012, 02:02 PM #1
Member
- Join Date
- Sep 2012
- Posts
- 2
- Rep Power
- 0
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
Java 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); }
- 09-11-2012, 02:46 PM #2
Re: How to compare variable with multiple variable?
I think I have done in my program the same but on a smaller scale.
I have buttons that let the user select 2 options.
Is that maybe what you would like?Java Code:if (StringA == "YES") { if (StringB == "YES") { System.out.println("Yes, Yes"); } }
- 09-11-2012, 03:55 PM #3
Re: How to compare variable with multiple variable?
Don't use == for comapring two Strings or other objects except when you really need to ascertain identity equality. Use the equals(...) method, which in a correctly written class, determines semantic equality: for Strings, that means the character content of the String.
dbWhy do they call it rush hour when nothing moves? - Robin Williams
- 09-11-2012, 04:06 PM #4
Re: How to compare variable with multiple variable?
Also posted at: How to compare variable with multiple variable?
If you don't understand my response, don't ignore it, ask a question.
- 09-11-2012, 04:28 PM #5
Member
- Join Date
- Sep 2012
- Posts
- 2
- Rep Power
- 0
Re: How to compare variable with multiple variable?
thanks
can you correct my code because i can't imagine how..
thank again.
- 09-11-2012, 04:33 PM #6
Re: How to compare variable with multiple variable?
The tutorial has examples of how to use methods:
http://docs.oracle.com/javase/tutori...arguments.htmlIf you don't understand my response, don't ignore it, ask a question.
Similar Threads
-
how to change an instance variable of an object from multiple arraylist references?
By smande3 in forum New To JavaReplies: 1Last Post: 07-07-2012, 10:12 PM -
Dynamic variable name based on other variable
By nadissen in forum EclipseReplies: 4Last Post: 05-06-2011, 06:22 PM -
How do I substitute any variable for a hardcoded variable
By Weazel Boy in forum New To JavaReplies: 11Last Post: 07-07-2010, 06:02 AM -
Issue with saving multiple times to a variable
By sidd0123 in forum New To JavaReplies: 3Last Post: 06-06-2010, 02:02 AM -
multiple declaration of a variable
By eva in forum New To JavaReplies: 2Last Post: 01-28-2008, 09:17 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks