28.04.2019 Views

[JAVA][Beginning Java 8 Games Development]

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>Java</strong> Relational Operators<br />

Chapter 3 ■ A <strong>Java</strong> 8 Primer: An Introduction to <strong>Java</strong> 8 Concepts and Principles<br />

The <strong>Java</strong> relational operators are used to make logical comparisons between two variables or between a variable<br />

and a constant, in some circumstances. These should be familiar to you from school and include equals, not equal,<br />

greater than, less than, greater than or equal to, and less than or equal to. In <strong>Java</strong>, equal to uses two equals signs side<br />

by side between the data fields being compared and an exclamation point before an equals sign to denote “not equal<br />

to.” Table 3-3 shows the relational operators, along with an example and a description of each.<br />

Table 3-3. <strong>Java</strong> Relational Operators, an Example in Which A = 25 and B = 50, and a Description of the<br />

Relational Operation<br />

Operator Example Description<br />

== (A == B) not true Comparison of two operands: if they are equal then the condition equates to true<br />

!= (A != B) is true Comparison of two operands: if they are not equal the condition equates to true<br />

> (A > B) not true Comparison of two operands: if left operand is greater than right operand, equates<br />

to true<br />

< (A < B) is true Comparison of two operands: if left operand is less than right operand, equates<br />

to true<br />

>= (A >= B) not true Compare two operands: if left operand is greater or equal to right operand equates<br />

to true<br />

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!