大家看看我的程序错在哪里
publicclassVehicle{intpassengers;intfuelcap;intmpg;voidrange(){System.out.println("Ra...
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: 我是一名初学者。编了很多小程序都没问题,这个问题始终没解决,请高手指教 展开
{
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: 我是一名初学者。编了很多小程序都没问题,这个问题始终没解决,请高手指教 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询