Here you can find the source of pow(int x, int y)
public static int pow(int x, int y)
//package com.java2s; //License from project: Open Source License public class Main { private static final int[][] INTEGER_POWERS = new int[50][50]; /**/*from w ww .ja va2 s.co m*/ * Positive integer powers. */ public static int pow(int x, int y) { if ((x >= 0) && (x < 50) && (y < 50)) { return INTEGER_POWERS[x][y]; } else { switch (y) { case 0: return 1; case 1: return x; case 2: return x * x; case 3: return x * x * x; default: if (y < 0) { throw new IllegalArgumentException("y " + y + " < 0"); } else { for (int i = 1; i < y; i++) { x *= x; } return x; } } } } }