如何用java接口,有两个方法:setPriority和getpriority,设计Task类Priority,建立驱动类测试Task对象?
1 回答
POPMUISE
TA贡献1765条经验 获得超5个赞
interface Jiekou{
public void setPriority(int i);
public int getPriority();
}
class Task implements Jiekou{
int i;
public void setPriority(int i){
this.i=i;
}
public int getPriority(){
return i;
}
}
public class TaskTest{
public static void main(String args[]){
int test;
Task task=new Task();
task.setPriority(6);
test=task.getPriority();
System.out.println(test);
}
}
添加回答
举报
0/150
提交
取消