Q:

I need a custom generic power method

this is my homework that I need to create a generic method to calculate the power.
Same as Math.pow(x,y); 
But x should generic and extends Number, y is an int number.
I can only push here.
public static <T extends Number> double power(T x, int y){

    double result = 0;

    for(int i=0; i<y; i++){

    }
    return result;
}

A:

This is homework, but I see you already wrote something. Here is my version (Caveat: my java is rusty).
public static <T extends Number> double power(T x, int y){
    /* I don't feel like calling this in a loop */ 
    double dx = x.doubleValue();
    double result = 1;

    for(int i=0; i<y; i++){
        result *= dx;
    }
    return result;
}

