Recursion Power function
public class Main { public static int power(int base, int expo) { if (expo == 0) { return 1;/*from w w w . j av a 2 s . c o m*/ } else return base * power(base, expo - 1); } public static void main(String args[]) throws Exception { int mResult = power(2, 3); System.out.print(mResult); } }