Java Learning Chapter III 4. Operations

Source: Internet
Author: User

the Java language contains operations: arithmetic operations, assignment operators, comparison operations, logical operations, bitwise operations, type-related operations.

1. Arithmetic operations: The arithmetic operations supported by Java include the subtraction operation, the remainder operation, and the self-addition or self-subtraction operation.

public class Div{public static void Main (String [] args) {Double A = 3.14;int B = 16;double c= a+b; System.out.println (c); System.out.println (A-B); System.out.println (A*B); System.out.println (A/b); System.out.println (a/0.0); System.out.println (a/0); System.out.println (A%B); System.out.println (a%0);d ouble d = a++ +2;double e = ++a + 2; System.out.println ("d=" +d+ "+" e= "+e);}}

  Java does not provide a exponentiation and root operation, and can be computed by the Java.lang.Math class tool.

  

public class Math{public static void Main (String [] args) {Double A = 3.2;double B = Math.pow (a,5); System.out.println (b);d ouble C = math.sqrt (a);d ouble d = math.random (); System.out.println (d);d ouble e = Math.sin (a); System.out.println (e);}}

Minus sign can be used to do negative arithmetic.

public class Qiufu{public static void Main (String [] args) {int x = -5;x =-X; SYSTEM.OUT.PRINTLN (x);}}

  

Java Learning Chapter III 4. Operations

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.