Java: How to write a condition for operators? [closed]

FYI: if() is not a loop while() is. if() statement works as true or false, if the statement is true then execute a certain code other wise some other code.

For example:

if(1==1){// yourcode } // Always as true
// or

String hello="hi there";
if(hello.contains("hi there")){ // Your code which if the statement happen to be true }
    else { // Not true}

int x=3, s=1, i=2;
if(x==(s+i)){ // Your code which if the statement happen to be true }
    else { // Not true}

also you can find a lot of tutorials online to help you better understand all the operators!

Leave a Comment