大家看看我的程序错在哪里public class Vehicle{int passengers;int fuelcap;int mpg;void range(){System.out.println("Range is"+fuelcap*mpg");}}class AddMeth{public static void main(String args[]){Vehicle minivan=new Vehicle();Vehicle sportsca
来源:学生作业帮助网 编辑:作业帮 时间:2024/08/27 02:20:43
大家看看我的程序错在哪里public class Vehicle{int passengers;int fuelcap;int mpg;void range(){System.out.println("Range is"+fuelcap*mpg");}}class AddMeth{public static void main(String args[]){Vehicle minivan=new Vehicle();Vehicle sportsca
大家看看我的程序错在哪里
public class Vehicle
{
int passengers;
int fuelcap;
int mpg;
void range()
{
System.out.println("Range is"+fuelcap*mpg");
}
}
class AddMeth
{
public static void main(String args[])
{
Vehicle minivan=new Vehicle();
Vehicle sportscar=new Vehiclel();
int range1,range2;
minivan.passengers=7;
minivan.fuelcap=16;
minivan.mpg=21;
sportscar.passengers=2;
sportscar.fuelcap=14;
sportscar.mpg=12;
System.out.print("Minivan can carry"+minivan.passengers+".");
miniva.range();
System.out.print("Sportscar can carry"+sportscar.passengers+".");
sportscar.range();
}
}编译时没有错,运行时就是Exception in thread "main"java.lang.NosuchmethodError:我是一名初学者.编了很多小程序都没问题,这个问题始终没解决,
大家看看我的程序错在哪里public class Vehicle{int passengers;int fuelcap;int mpg;void range(){System.out.println("Range is"+fuelcap*mpg");}}class AddMeth{public static void main(String args[]){Vehicle minivan=new Vehicle();Vehicle sportsca
不知道你运行的哪个类,是AddMeth吗?