PruebaStatic.java 479 Bytes
Newer Older
Nelson Ruiz committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
class Factura{
    private static  float iva1;
    public Factura(int n){
        iva1=n;
    }

    public static float getIva(){//solo puede retornar variables estaticas
        return iva1;//si iva1 no es static va a dar un error
    }


}


public class PruebaStatic {
    public static void main(String[] args) {
        Factura f1=new Factura(5);
        Factura f2=new Factura(4);
        System.out.println(f1.getIva());
        System.out.println(f2.getIva());

    }
}