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