什么是测试类?

来源:百度知道 编辑:UC知道 时间:2024/09/24 14:09:45
JAVA中的测试类是用来干什么的?还有应该怎样编写?.
用下面的代码做下例子说明下怎样写测试类
3Q

public class MyMath {

public static int Max(int a,int b,int c) {
return (((a>b)?a:b)>c)?((a>b)?a:b):c;
}
public static void main (String[] args) {
System.out.print(MyMath.Max(3,4,5));
}

}

测试类 顾名思义就是用来测试的类
public class MyMath {
public static int Max(int a,int b,int c) {
return (((a>b)?a:b)>c)?((a>b)?a:b):c;
}
}

*****测试类******
public class TestMyMath{
public static void main (String[] args) {
MyMath mm=new MyMath();
System.out.print(mm.Max(3,4,5));
}
}