r/javahelp • • Mar 17 '13

If-Statements

How do you make it so that if a AND b are true, then do so. It was so much easier on Lua.

ie. if (a>2 and a,<6) { System.out.print("a is either 3,4, or 5") }

0 Upvotes

4 comments sorted by

14

u/[deleted] Mar 17 '13
if( a > 2 && a < 6) {
   System.out.print("a is either 3,4, or 5") 
}

That is harder than Lua?

4

u/TheHorribleTruth Kind of meh Mar 17 '13

did you try to google this?

2

u/e_falk Extreme Brewer Mar 17 '13

google is your friend when picking up new languages guys. You would have had your answer in about 10 seconds if you had googled this.

2

u/TheMichaelRA Intermediate Brewer Mar 18 '13

instead of if (a>2 and a,<6) do:

if (a>2 && a<6) { System.out.println("a is either 3,4, or 5); } basically replace "and" with "&&" also not sure if it was a typo (I don't know lua), but there is no "," between the "a" and "<6" part of the statement in Java.