Got Homework?
Connect with other students for help. It's a free community.
Here's the question you clicked on:
 0 viewing
Pradius
Group Title
Java Programming..
If I want to use the If statement to say :
If (x > 4 and <9){}
What operator should I use? or what method?
 3 years ago
 3 years ago
Pradius Group Title
Java Programming.. If I want to use the If statement to say : If (x > 4 and <9){} What operator should I use? or what method?
 3 years ago
 3 years ago

This Question is Closed

jeffersonw Group TitleBest ResponseYou've already chosen the best response.0
and is "&&"
 3 years ago

jeffersonw Group TitleBest ResponseYou've already chosen the best response.0
so it would be If(x>4 && X<9){}
 3 years ago

Pradius Group TitleBest ResponseYou've already chosen the best response.0
yeah but that operator is not working...
 3 years ago

jeffersonw Group TitleBest ResponseYou've already chosen the best response.0
&& is the logical "and" operator to compare two boolean values, should be working
 3 years ago

1ncident Group TitleBest ResponseYou've already chosen the best response.0
try putting it in parentheses so if ((x>4)&&(x<9))
 3 years ago

fr33 Group TitleBest ResponseYou've already chosen the best response.3
if(( x > 4) && (X < 9 )) { //Do something here. } Hey! That's exactly I was going to post lol
 3 years ago

Pradius Group TitleBest ResponseYou've already chosen the best response.0
There you go , That's exactly what I was looking for.. I was trying something like that but without some parenthesis If (x >4)&(<9) but I forgot that theres only one condition so everything must be within a set of parenthesis. Thanks man!
 3 years ago

rsmith6559 Group TitleBest ResponseYou've already chosen the best response.0
Just so you know, the single ampersand is a legal operator. It's used for bitwise and.
 3 years ago

tuhinrawat90 Group TitleBest ResponseYou've already chosen the best response.0
if(x>4 && x<9 ) { // your stuff }
 3 years ago

Creperum Group TitleBest ResponseYou've already chosen the best response.0
There's also the assignment conditional operator used for singular assignments. a = (b > c) ? b : c; So if b is greater than c, a takes the value of b, otherwise it takes the value of c. More formally, this is read as: value = (condition) ? (true value) : (false value); The condition can be any valid conditional statement, as long as it validates before the ? operator.
 3 years ago
See more questions >>>
Your question is ready. Sign up for free to start getting answers.
spraguer
(Moderator)
5
→ View Detailed Profile
is replying to Can someone tell me what button the professor is hitting...
23
 Teamwork 19 Teammate
 Problem Solving 19 Hero
 Engagement 19 Mad Hatter
 You have blocked this person.
 ✔ You're a fan Checking fan status...
Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.