In Java, the most efficient way is to calculate the number equal to 2 multiplied by 8?
2 <3,
Because moving a number to the left is equivalent to multiplying it by the N power of 2. Then, if a number is multiplied by 8, you only need to shift it to the left by three places.
The bit operation CPU directly supports the highest efficiency. Therefore, the most efficient method of multiplying 2 by 8 is 2 <3.
// Calculate 2*8 = 2*23
System. Out. println (2 <3); // The third time of system. Out. println = 2 is 8.
// Calculate 2*16 = 2*24
System. Out. println (2 <4); // The four times of system. Out. println = 2 are 16.
// Calculate 3*8 = 2*23
System. Out. println (3 <3); // The third time of system. Out. println = 2 is 8.
// Calculate 5x8 = 5x23
System. Out. println (5 <3); // The third time of system. Out. println = 2 is 8.
// Calculate 6*4 = 6*22
System. Out. println (6 <2); // 2 times of 4 = 2 is 4
Javacode
Int I = 1;
System. Err. println (I-= I + = I-= I --);