Math.pow(2,n)。
详细解释:
这不就是多个2相乘么,
public class test1 {
public static void main(String[] args) throws Exception {
int a = 1;
int n = 3;
for (int i = 0; i < n; i++) {
a = a*2;
}
System.out.println(a);