Question

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);
    }       

}
Was it helpful?

Solution

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);
    }  
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top