Java Note Two

Source: Internet
Author: User

JAVA Note two

Constant : represents a value that cannot be changed

Variables : Storing indeterminate data is a space that needs to be opened in memory

How to open up memory space?

is through explicit data type variable name data to complete

integer.tobinarystring (number);

JAVA provides a way to convert binary binary ;

number represents the converted to binary digits

Two variables do not pass the third variable for two worth of exchange

1.int a=3,b=8;

A=a+b;

A=a-b;

B=a-b;

There are limitations to this approach, such as a+b greater than 2^32-1 , which can cause errors

We can exchange by an XOR operation, a number XOR or a number two times equal to the original number.

2.int a=3,b=8;

A=a ^ b;//b

B=a ^ b;//(a ^ b) ^ b

a=a ^ b;//a ^ (a ^ b)

differences between for and while loops

1. The variable has its own scope, and for the for : if the increment of the control loop is defined in the for statement. Then only Valid within the FOR statement, The variable is freed by memory after the for statement executes

2.for and while can be swapped in, if you need to define the loop increment, use the For loop for the appropriate

Java Note Two

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.