SobreCarga.java 652 Bytes
Newer Older
Joel Florentin committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
public class SobreCarga {
    static class Operaciones{
        public static int elevarAlCuadrado(int num) {
            return num*num;
        }
        public static float elevarAlCuadrado(float num){
            return num*num;
        }
        public static double elevarAlCuadrado(double num){
            return num*num;
        }
    }
    public static void main(String[] args) {
        System.out.println("Elevando un entero "+Operaciones.elevarAlCuadrado(3));
        System.out.println("Elevando un double "+Operaciones.elevarAlCuadrado(5.5));
        System.out.println("Elevando un float "+Operaciones.elevarAlCuadrado(3.0f));
    }
}