0

java class method

package pakage2; class vehicle { int passengers; int fuelcap; int mpg; void range(){ System.out.println("range is"+ fuelcap*mpg); } } class Addmeth { public static void main(vehicle args[]){ vehicle minivan = new vehicle (); vehicle sportscar = new vehicle(); int range1,range2; // assign value of minivan field minivan.passengers= 7; minivan.fuelcap= 16; minivan.mpg =21; // assign value of sportscar field sportscar.passengers = 2; sportscar.fuelcap = 14; sportscar.mpg =12; // minivan range statement System.out.print("minivan can carry "+minivan.passengers+"."); minivan.range(); // sportscar range statement System.out.print("sportscar can carry "+ sportscar.passengers+"."); sportscar.range(); } } An error ocurred : Error: Could not find or load main class lesson1.myclass need help

31st Dec 2016, 4:09 AM
Great Srrr
Great Srrr - avatar
1 Answer
+ 1
You jave vehicle[]args as arguments for main. It must be String[]args
31st Dec 2016, 7:58 AM
Roman GrÀf
Roman GrÀf - avatar