cannot find symbol; symbol : constructor error

Hi,

I am fairly new to java and working on an inheritance example and I get the following error """TestAuto.java": cannot find symbol; symbol : constructor Auto(java.lang.String,java.lang.String,java.lang.String,java.lang.String), location: class Auto at line 9, column 17" and ""TestAuto.java": internal error; cannot instantiate Auto.<init> at Auto to () at line 6, column 17" in this program. Each instantiation comes up with a similar error.

From everything I have looked at I am trying to create/initialize it correctly.I know it must be something simple. Please help.

file Auto.java"

import java.io.*;

public class Auto {

private String make = " ";

private int cylinders = 0;

private String transmission = " ";

private String color = " ";

private String autodetails = " ";

public Auto(String autoMake, int autoCylinders, String autoTransmission, String autoColor) {

make = autoMake;

cylinders = autoCylinders;

transmission = autoTransmission;

color = autoColor;

}

public String printInfo(){

autodetails = "A " + color + ", " + transmission + " transmission, v" + cylinders + make + " automobile.";

return(autodetails);

}

}

class Truck extends Auto {

int towCapacity;

int groundClearance;

private String truckdetails;

public Truck(String truckMake, int truckCylinders, String truckTransmission, String truckColor, int truckTowCapacity, int truckGroundClearance)

{

super(truckMake, truckCylinders, truckTransmission, truckColor);

towCapacity = truckTowCapacity;

groundClearance = truckGroundClearance;

}

public String printInfo() {

truckdetails = super.printInfo() + " truck with " + towCapacity + " lbs of towing capacity and " + groundClearance + "inches of ground clearance.";

return(truckdetails);

}

}

class Car extends Auto {

int doors;

int mpg;

private String cardetails = " ";

public Car(String carMake, int carCylinders, String carTransmission, String carColor, int carDoors, int carMPG) {

super(carMake, carCylinders, carTransmission, carColor);

doors = carDoors;

mpg = carMPG;

}

public String printInfo(){

cardetails = super.printInfo() + "car with " + doors + " getting " + mpg + " MPG.";

return(cardetails);

}

}

file "TestAuto.java"

import java.io.*;

public class TestAuto {

public static void main (String args[]) throws IOException

{

Auto auto = new Auto("Pontiac", "8", "Auto", "Red");

Truck truck = new Truck("Chevy", "8", "Auto", "Black", "5000", "13");

Car car = new Car("Corvette", "8", "Manual", "White", "2", "23");

System.out.println(auto.printInfo());

System.out.println(truck.printInfo());

System.out.println(car.printInfo());

}

}

[2950 byte] By [jamesh2a] at [2007-11-26 21:10:49]
# 1

Look at your parameter:

public Auto(String autoMake, int autoCylinders, String autoTransmission, String autoColor)

Now, look how you created it in main:

Auto auto = new Auto("Pontiac", "8", "Auto", "Red");

Is "8" an integer, or a string?

;-)

shlumpha at 2007-7-10 2:47:53 > top of Java-index,Java Essentials,New To Java...
# 2

public class TestAuto {

public static void main (String args[]) {

Auto auto = new Auto("Pontiac", 8, "Auto", "Red");

Truck truck = new Truck("Chevy", 8, "Auto", "Black", 5000, 13);

Car car = new Car("Corvette", 8, "Manual", "White", 2, 23);

System.out.println(auto.printInfo());

System.out.println(truck.printInfo());

System.out.println(car.printInfo());

}

}

Note that "5000" is a string literal and 5000 is an int literal.

That was the only sort of mistake you made.

Good Luck, and don't forget about electric cars!

DrLaszloJamfa at 2007-7-10 2:47:54 > top of Java-index,Java Essentials,New To Java...
# 3

Guys,

Thanks. I noticed I had copied the last two parameters in Truck and Car wrong putting the " " around the numbers. The first 4 parameters are strings and the last two are int's. I removed the quotes from the last two parameters and it still popped up with the same error.

I cannot figure out what is going on with it and the JBuilder I am using is not helping much on the debugging.

jamesh2a at 2007-7-10 2:47:54 > top of Java-index,Java Essentials,New To Java...
# 4
> The first 4 parameters are strings and the last two are int's.But as observed in the previous replies the second parameter is declared (andused in the Car constructor) as an int not a string.
pbrockway2a at 2007-7-10 2:47:54 > top of Java-index,Java Essentials,New To Java...
# 5
Thanks, all. It was a combination of wrong data types defined and another typo in the coding. I finally got it working this afternoon.
jamesh2a at 2007-7-10 2:47:54 > top of Java-index,Java Essentials,New To Java...