Java programming things 22-comparison Operators

Source: Internet
Author: User

Java programming those things 22-comparison operators Zhengzhou game college Chen yuefeng from: http://blog.csdn.net/mailbomb 4.2 comparison OperatorsComparison operators are used to compare the data sizes or equal values. The comparison operator returns a Boolean value. If the comparison result is true, the result is true. Otherwise, the result is false. For the Expression and Function of comparison operators in Java, see Table 4-2. Table 4-2 Comparison Operators
Symbol Name Function Description
> Greater Compare whether the number on the left is greater than the number on the right
< Less Compare whether the number on the left is smaller than the number on the right
> = Greater than or equal Compare whether the left digit is greater than or equal to the right digit
<= Less than or equal Compare whether the number on the left is less than or equal to the number on the right
= Equal Compare whether the left digit is equal to the right digit
! = Not equal Compare whether the left digit is not equal to the right digit
The calculation rules of comparison operators are the same as those in reality. Note the following: The L boolean type can only be equal or not equal, but cannot be larger. L> = indicates that the value is greater than or equal to. Therefore, 5> = 5 is true. L The range [) expressed in mathematics, that is, the number is greater than or equal to 1 and less than 10. the following format cannot be written in the program: 1 <= n <10, this writing is syntactic incorrect. If you need to express this interval, see section 4.3 logical operator implementation. L be especially careful when determining whether equal symbols are two equal signs rather than one equal sign. The example code used for the comparison operation is as follows: int A = 10; Boolean B = (A> 3); // The condition is true, the value true is assigned to the variable B Boolean c = (B = true); // The condition is true and the result is true in the actual code, values, variables, and calculation results can be directly involved in the comparison, but in order to enhance readability in the program, sometimes the comparison needs to be written separately. Comparison operators are the basis for data comparison in programming and also the basis for many logical implementations. In program logic, we often compare certain conditions to determine how to execute subsequent programs.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.