Basically, relational operator structure looks like above. Same as if else statement in logic, but differ in coding. Example: You will make a program that will determine your grade "PASSED" or "FAILED". For beginners, first JAVA program please read this First JAVA program.
//if else
if (grade>=50)//pass
System.out.println ("PASSED"); //pass if 50 above
else
System.out.println ("FAILED"); //else(otherwise) failed
//for relational operator
System.out.println(grade>=50?"PASS":"FAILED);
See the difference?
SHARE and LEARN!
No comments:
Post a Comment