Java Learning Notes 02--operators, expressions

Source: Internet
Author: User

Assignment Operation symbols

Unary operators

Arithmetic operators

Relational operators

Increment and decrement operators

PublicClassT{PublicStaticvoidMain(String[]Args){IntA=3,B=3;Define two variables A and bIntX=6,Y=6;Define two variables x and ySystem.Out.println("A ="+A);System.Out.println("\ t a++ ="+(A++)+", a ="+A);The first calculation after the self-incrementSystem.Out.println("B ="+B);System.Out.println("\ t ++b ="+(++B)+", B ="+B);First self-increment after calculationSystem.Out.println("x ="+X);System.Out.println("\ t x--="+(X--)++ x) //first calculated auto minus system.. ( "y =" + y) system.. ( "\ t--y =" +  (--y+ + y //first subtract            

Result of Operation

a = 3       a++ = 3 , a = 4  b = 3       ++b = 4 , b = 4  x = 6       x-- = 6 , x = 5  y = 6       

logical operators

Whether it is a short-circuit or a non-short-circuit, its basic operating results are the same.

The following error codes are available:

public class T {      public static void main(String[] args) { int i = 10/0; System.out.println(i); } } 

The code above will cause problems as soon as it runs.

public class t {public static void main (string [] args) {if10!=10&10 /0==0) {system out. ( "condition satisfies" } } }          /span>                

Short Circuit and

public class t {public static void main (string [] args) {if10!=10&&10 /0==0) { System.. ( "condition satisfies" } } }          /span>                

As long as the first condition is satisfied, then the program code is not executed.

Bitwise operators

Result table of the bitwise operator

PublicClassT{PublicStaticvoidMain(String[]Args){IntX=3;3 binary data: 00000000 00000000 00000000 00000011IntY=6;6 binary data: 00000000 00000000 00000000 00000110System.Out.println (x & y  //with: 00000000 00000000 00000000 00000010 system. Out. (x | y //or: 00000000 00000000 00000000 00000111 system. Out. (x ^ y)  Span class= "C1" >//or: 00000000 00000000 00000000 00000101 } }     

Copyright NOTICE: This article uses the BY-NC-SA agreement to authorize, reproduced the Wheat Field Technical blog article please indicate the source

Original address: Http://itmyhome.com/2015/03/java-study-notes-operator-expression

Java Learning Notes 02--operators, expressions

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.