Domanda

how to carry test on the class below with System.out in java - where and how should i put the System.out script

public class DtaPlusMethods {

    public static void main(String[] args) {

    }

    private double a = 1.0;
    private double b = 2.0;
    private double c = 3.0;

    private DtaPlusMethods()
    {// Empty Constructor   
    }

    private double Mean()
    {
        c = (a + b)/2;
        return(c);
    }       

}
È stato utile?

Soluzione

public class DtaPlusMethods {
    private double a = 1.0;
    private double b = 2.0;
    private double c = 3.0;

    public static void main(String[] args) {
        DtaPlusMethods thisClass= new DtaPlusMethods();
        System.out.println(thisClass.Mean());

    }

    private double Mean()
    {
        c = (a + b)/2;
        return(c);
    }  
}
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top