Arithmetic operators for the Java Foundation

Source: Internet
Author: User
Tags arithmetic arithmetic operators

http://www.verejava.com/?id=16992579787012

/*1. 算数运算*/public class Operation{    public static void main(String[] args)    {        //1. 算数运算 加+,减-,乘*,整除/,取模%,自减--,自增++        int a=1;        int b=2;        int c=3;        int d=4;        System.out.println(a+b);        System.out.println(a-b);        System.out.println(a*b);        System.out.println(b/a);        System.out.println(a/b);        //取模就是整除后余下的数        System.out.println(c%b);        System.out.println(d%b);        System.out.println(4%-3);        System.out.println(-4%-3);        System.out.println(-4%3);        System.out.println(d++);        System.out.println(++d);        System.out.println(d--);        System.out.println(--d);        /*        注意:            1. 整除的时候会自动切除小数部分            2. 取模的时候结果值的正负取决于分子的符号            3. 对于自增++在变量后面时是先输出,再加1, 如果++放在变量前面则是先加+再输出计算。            4. 对于自减在变量后面时是先输出再减1,如果放在变量后面是先减1再输出计算        */    }}

http://www.verejava.com/?id=16992579787012

Arithmetic operators for the Java Foundation

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.