Ask your own question, for FREE!
Computer Science 15 Online
OpenStudy (mokeira):

Someone please explain to me in simple terms the function of various conditional statement and how or where they are used... thank you

OpenStudy (woodrow73):

Are you referring to the conditional ternary operator? I can show you the java version.

OpenStudy (mokeira):

I mean things like the if statement...i do not know if we are talking of the same

OpenStudy (immanuelv):

For simplicity, we will refer to the first line as the if clause. The if clause begins with the word if, followed by a condition, which is an expression that will be evaluated as either true or false.

OpenStudy (immanuelv):

if condition: statement statement // this is for python

OpenStudy (mokeira):

it is similar in java as well, i believe...so will the program will keep running if the statement is true?

OpenStudy (immanuelv):

yes... you can have else if or else statements as well to tell your program what to do if certain condition is not met

OpenStudy (woodrow73):

if you want the program to end when the condition is false - you can use the ! operator, ``` boolean condition = false; if(!condition) System.exit(0); ``` that will end the program if it's false. for general if else statements -- ``` if(boolean variable == true) { //do these statements } else { //do these statements } ```

OpenStudy (mokeira):

does the 0 inside System.exit(0); have any significance?

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!