javase-arithmetic operators

Source: Internet
Author: User
Tags arithmetic arithmetic operators

Arithmetic operators include: + 、-、 *,/,%, + + 、--

Code:

Package com.java.chap02;

public class Demo07 {

public static void Main (string[] args) {
int a=10;
int b=3;
+ operator
System.out.println (A + "+" +b+ "=" + (a+b));
-Operator
System.out.println (A + "-" +b+ "=" + (a) ");
* operator
System.out.println (A + "*" +b+ "=" + (a*b));
/operator
System.out.println (A + "/" +b+ "=" + (A/b));
% operator
System.out.println (A + "%" +b+ "=" + (a%b));

int a1=1;
a1++; Indicates that the assignment operation is done first, and then the self-increment
int b1=a1++;
System.out.println ("b1=" +b1);
System.out.println ("a1=" +a1);

System.out.println ("================");

int a2=1;
++a2; means to increment first and then do assignment
int b2=++a2;
System.out.println ("b2=" +b2);
System.out.println ("a2=" +a2);


}
}

javase-arithmetic operators

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.