The process control of my Java path

Source: Internet
Author: User

Arithmetic operators:

  Plus (+), minus (-), multiply (*), divide (/), withdraw (%)

Integer division directly cuts down decimals, not rounding

 Public class mathtest{    publicstaticvoid  main (string[] args) {          int i = 3;         int j = 2;         int Math = I/ j;        System.out.println (Math);}    }

Value for output math: 1

int i = 3;int j = 2; System.out.println (i/j);

Same as the previous program with output 1.

 Public class mathtest{    publicstaticvoid  main (string[] args) {        int i = 3;         int j = 2;         Double Math = I/ j;        System.out.println (Math);}    }

The value of the output math is: 1.0.

 Public class mathtest{    publicstaticvoid  main (string[] args) {        double i = 3;         // Double j = 2; same as        output from next line int j = 2;         Double Math = I/ j;        System.out.println (Math);}    }

The value of the output math is: 1.5.

To increment or decrement automatically:

 Public class mathtest1{    publicstaticvoid  main (string[] args) {        int a = 7;         int i = a++ + 3 ;        System.out.println ("a =" + a);        System.out.println ("i =" + i);}    }

Output: a = 8 i = 10

 Public class mathtest1{    publicstaticvoid  main (string[] args) {        int a = 7;         int i = ++a + 3 ;        System.out.println ("a =" + a);        System.out.println ("i =" + i);}    }

Output: a = 8 i = 11

Summary: int i = a++ + 3 is run first i = a + 3 and then run a = a + 1;

int i = ++a + 3 is run first A = a + 1 and then run i = a + 3;

If more complex operations need to be done, complex mathematical operations can be accomplished using the Java.lang.Math class's tool approach.

 (Descending with sliding scale)

Relational operators

  The relational operator generates a Boolean result. They evaluate the relationship between the operands ' values. If the relationship is true, the relational expression generates true (True), and False (false) if the relationship is not true. Relational operators include less than, greater than (>), less than or equal to (<=), greater than or equal to (>=), equals (= =), and not equal to (! =). equals and does not equal all built-in data types, but other comparisons do not apply to Boolean types.

Logical operators:

logical operators and (&&), or (| |) and NOT (! ) can generate a (true or false)-based on the logical relationship of the arguments.

If you expect to

The process control of my Java path

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.