Java operator--2017.08.01

Source: Internet
Author: User

Package Collection;
Difference between division operation and remainder operation public class Div {public static void main (string[] args) {//TODO auto-generated method Stubint Int1=5;int I Nt2=2;double double1=2.0;//Division operation result System.out.println (INT1/INT2); System.out.println (int1/double1); /* * 2 * 2.5 *///% for redundancy Operation System.out.println (int1%2); System.out.println (double1%0);//nan: Non-number}}

  

The difference between package Collection;//++a and a++ public class Leijia {public static void main (string[] args) {//TODO auto-generated method stub    int a=10;    System.out.println (a++);    System.out.println (a);    System.out.println (++a);   }} Ten       ///      12

  

Package collection;//comparison operator public class Bijiao {public static void main (string[] args) {//TODO auto-generated method stub int int1=453;float float1=453f; System.out.println (INT1==FLOAT1);//==, the two sides can only be numeric types, as long as the values are equal, the data type can be different//output true}}

  

Package Collection;public class Logicoperator {public static void main (string[] args) {//TODO auto-generated method Stubi NT A=5;int b=6;int c=8;//&& comparison with &/    if (a>3 && b++>4)//{//system.out.println (A + "   " + b);//}////here output results a=5   b=7//if (a>4 & ++c>2)//{//system.out.println (A + "   " +c);//}////5   9//   // || and | comparison//if (a>3 | | c++>3)//{//SYSTEM.OUT.PRINTLN (A + "  " +c);//}///output: 5  8if (a>3 | c++>3) { System.out.println (A + "  " +c);} Output 5  9}      }

The difference between && and &, | | As with |, the future is illustrated by an example, when | As long as two operands (before and after operands), the first operand is true, the post operand does not operate, and | | The post-operand will operate regardless of whether the preceding operand is bit true.

Package Collection;public class Threecharacters {//Three mesh operator public static void main (string[] args) {      int a=11;      int b=12;      System.out.println (a<b? "A is less than B": "A is greater than B");      The Trinocular operator form is: (expression)? If-true-statement:if-false-statement}}

  

Java operator--2017.08.01

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.