Java===java Basic Learning (2)---operator, ternary operator, mathematical function

Source: Internet
Author: User
Tags cos mathematical functions sin

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

Related Article

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.