Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Java Java Basics Perfecting the Prototype Using Logical ORs and ANDs

mahesh gurbaxani
mahesh gurbaxani
1,420 Points

the if statement

IF I wanted to have an "if" clause for variable integer age is greater than 30 AND less than 80, can i code it like this: if(age>30&&<80) If not, how should I do it?

2 Answers

You would just need to use the following code to check whether the number is more than 30 and less than 80.

if (age > 30 && age < 80) {
    //Insert Code To Run.
}
Yongshuo Wang
Yongshuo Wang
5,500 Points

You can use operator !

if (! (age > 30 && age < 80)){

}