The main introduction is operators, and mathematical functions as well as ternary operators:
PackageTestbotoo; Public classTest1 { Public Static voidMain (string[] args) {intA = 122;SYSTEM.OUT.PRINTLN ("The result of calling operation is:" +operation (a));//call the method defined below };
Public Static intOperation (intv) { intXe = v + 1; intand = 10; returnXE; }}
operator, basically similar to Python, except for the use of the && expression and, by | | Represents or:
/* Relational Operators */ && expression2 // equivalent to expression1 and expression2 in Python expression1 | | Expression2 // equivalent to expression1 or expression2 in Python
Ternary operators:
/* ternary operator */ ? expression1:expression2 // evaluates the first expression when the condition condition is true, otherwise evaluates the second expression
For example:
x < y? X:y
The above is the smallest one in X and Y.
Common mathematical functions:
is equivalent to built-in functions, some of the methods that have been implemented belong to the math class.
Math.sin
Math.Cos
Math.exp
Math.log
Math.log10
... ...
When you use it, import it first:
Import Static java.lang.math.*
This eliminates the hassle of adding math. Direct use, Sin,cos,tan and so on.
Java===java Basic Learning (2)---operator, ternary operator, mathematical function