调试一程序
import java.util.*;
interface fly{
void start();
void land();}
class Airplane implements fly{
int meal;
int lunch;
public void start(int a){
meal=a;
}
public void land(int b)
{lunch=b;}
int getstart(){return meal;}
int getland(){return lunch;}
}
public class Ok{
public static void main(String[] args){
Airplane c=new Airplane();
c.start(10);
c.land(20);
System.out.println( "this is value: "+c.getstart());
System.out.println( "this is value: "+c.getland());}
}
请各位高手看看这个错误到底是错在哪里
------解决方案--------------------import java.util.*;
interface fly {
void start(int a);
void land(int a);
}
class Airplane implements fly {
int meal;
int lunch;
public void start(int a) {
meal = a;
}
public void land(int b) {
lunch = b;
}
int getstart() {
return meal;
}
int getland() {
return lunch;
}
}
public class Example {
public static void main(String[] args) {
Airplane c = new Airplane();
c.start(10);
c.land(20);
System.out.println( "this is value: " + c.getstart());
System.out.println( "this is value: " + c.getland());
}
}
你接口中的方法必须也是带参数的
------解决方案--------------------1楼说的对.