/** 
* Java得到一个整数的绝对值,不使用任何判断和比较语句,包括API. <br> 
* 1、不得使用任何API,如Math.abs()等。<br> 
* 2、不得使用判断语句,如if、for、while、switch、?:等。<br> 
* 3、不得使用比较语句,如:==、 <=、>=、!=、 <、>等。 <br> 
* 
* @author JAVA世纪网(java2000.net, laozizhu.com) 
*/ 
public class Test { 
public static void main(String[] args) { 
for (int i = -5; i <= 5; i++) { 
System.out.println(abs(i)); 
} 
} 
public static int abs(int num) { 
return num * (1 - ((num >>> 31)<<1)); 
} 
}