1 package bitOperation; 2 3 import java.util.Scanner; 4 5 /** 6 * @author zsh 7 * @company wlgzs 8 * @create 2019-02-14 15:54 9 * @Describe 题4:是不是2的整数次方 10 * 用一条语句判断一个整数是不是2的整数次方 11 */ 12 public class Main4 { 13 public static void main(String[] args) { 14 Scanner scanner = new Scanner(System.in); 15 int n = scanner.nextInt(); 16 if (((n-1) &n) == 0){ 17 System.out.println(true); 18 }else { 19 System.out.println(false); 20 } 21 22 } 23 }