/** 
* 编程计算3乘8等于几,什么方法效率更高? 
 */ 
public class Test { 
         
        public static void main(String[] args) { 
                int a = 3 << 3;                                  //3左移三位计算效率最高。 
                System.out.println(a); 
 
                int b = 3 * 8;                                        //计算3 * 8 的普通方法效率比较低。 
                System.out.println(b); 
        } 
 
} 
 
/* 
*   不定义第三方变量,交换n=4,m=5的值,用位运算和求和 
*/ 
 
int n=4,m=5; 
n=n^m; 
m=n^m; 
n=n^m; 
---------------------- 
n=n+m; 
m=n-m; 
n=n-m 
 |   
        
 
    
    
    
     
 
 |