如何使用java中的System.out对下面的类进行测试 - 我应该在哪里以及如何放置System.out脚本
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);
}
}
答案 0 :(得分:1)
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);
}
}