Java By Example PHẦN 3

Các biểu thức được những gì các lập trình viên như cuộc gọi đệ quy, có nghĩa rằng định nghĩa của một biểu thức tiếp tục trở lại trên chính nó. Một biểu thức có chứa các biểu thức có chứa các biểu thức khác, mà bản thân có chứa các biểu thức khác. | But wait a second-you re not done yet. You can still find more sub-expressions. Look at the multiplication operation. Can you see that it s multiplying two expressions together Those two expressions look like this 5 - x 2 y And the above simplified expressions contain yet more sub-expressions. Those expressions are 5 x 2 y Expressions are what programmers like to call recursive meaning that the definition of an expression keeps coming back on itself. An expression contains expressions that contain other expressions which themselves contain other expressions. How deep you can dig depends on the complexity of the original expression. But as you saw demonstrated even the relatively simple expression num 5 - x 2 y has four levels of depth. Comparison Operators Now that you ve dug into the secrets of expressions it s time to learn about a new type of operator. So far you ve gotten some practice with mathematical operators which enable you to build various types of numerical and assignment expressions. Another type of operator you can use to build expressions is the comparison operator. Comparison operators are used to create logical expressions which if you recall result in a value of true or false. Table lists the logical expressions used in Java programming. C and C programmers will find these operators very familiar. Table Java s Logical Operators. Operators Description Equal to Less than Greater than Less than or equal to Greater than or equal to Not equal to Example Using Comparison Operators Just how do you use comparison operators As their name suggests you use them to compare two expressions with the result of the comparison being either true or false. For example look at this logical expression 3 2 1 The result of the above expression is true because the operator determines whether the expressions on either side are equal to each other. If you were to change the expression to 3 2 2 the result would be false. That is 3 does not equal 4. However the .

Không thể tạo bản xem trước, hãy bấm tải xuống
TÀI LIỆU MỚI ĐĂNG
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.