kirky_D Posted November 27, 2006 Posted November 27, 2006 Ok, so i'm a bit of a beginner at java, i've searched google to no aveil. Is there a way to have more than one statement in an 'if' operation? e.g. (english worded) if a = b AND c = d then I have found out how to use the 'or' bit in an if statement by using '|' but i cant manage AND, can anybody help me? Share this post Link to post Share on other sites More sharing options...
Verran Posted November 27, 2006 Posted November 27, 2006 '|' is to OR as '&' is to AND. & is the symbol you want to use for logical AND statements Share this post Link to post Share on other sites More sharing options...
kirky_D Posted November 27, 2006 Posted November 27, 2006 Sweet, cheers! Share this post Link to post Share on other sites More sharing options...
UMTopSpinC7 Posted November 27, 2006 Posted November 27, 2006 '|' is to OR as '&' is to AND. & is the symbol you want to use for logical AND statements Just a note.... & is different than && (same with | and ||). One is a bitwise operator and the other is a logical operator. In most cases if you are using AND in a if statement to test if two conditions are both true you want to use && not &. Here is a link about it. Share this post Link to post Share on other sites More sharing options...
hardnrg Posted November 27, 2006 Posted November 27, 2006 (edited) java is very similar to c/c++... the equality is the same as well, so conditional equality testing is ==, assignment is = if(a==b && c==d) { // do some stuff if the conditions were met e = 7; // sets the value of e to 7 } else { // do some stuff if the conditions were not met } //endif Edited November 27, 2006 by hardnrg Share this post Link to post Share on other sites More sharing options...
Nerm Posted November 27, 2006 Posted November 27, 2006 I recommend using nested if/else statements like nrg suggested. Share this post Link to post Share on other sites More sharing options...
CheeseMan42 Posted November 27, 2006 Posted November 27, 2006 i concur. i miss the days of programming in java.... Share this post Link to post Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now