int base, exponent, power; base = ...; exponent = ...; power = 1; while (exponent > 0) { power = power * base; exponent--; } System.out.println("power = " + power);