Cannot find symbol error

With the following code:

/**

* TestActor is a console class that is used to test the Actor class.

*

* The initial version of TestActor instantiates an instance of Actor using

* the 'four parameter constructor' and then determines the Title of the

* actor's latest film.

*

* It is envisaged that students will write additional 'main' code

* to fully test their Actor class.

*

* Created:

*

* @author

* @version

*/

publicfinalclass TestActor{

publicstaticvoid main (String [] args){

// instantiate an instance of Actor without specifying their latest

// film

Actor myActor =new Actor ("Julie","Walters", 52, Actor.FEMALE);

System.out.println("(1) Lastest film is " + myActor.getFilmTitle () );

myActor.setFilmTitle ("Educating Rita");

System.out.println("(2) Lastest film is " + myActor.getFilmTitle () );

System.out.println("(3) Actor is:\n\n" + myActor.toString () +"<end>");

}// end of main method

}// end of class Actor

I get the followng error:

TestActor.java:25: cannot find symbol

symbol : constructor Actor(java.lang.String,java.lang.String,int,int)

location: class Actor

Actor myActor = new Actor ("Julie", "Walters", 52, Actor.FEMALE);

^

1 error

I was wondering if anyone could shed any light on it for me as I'm having problems rectifying the error, thanks.

[2199 byte] By [bmzra] at [2007-10-3 9:20:29]
# 1
From the code you posted, all I can tell you is that the compiler can not find a constructor in the Actor class that takes 2 Strings and 2 ints. You should post the Actor class if you need more help.
atmguya at 2007-7-15 4:33:49 > top of Java-index,Developer Tools,Debugging and Profiling Tool APIs...
# 2

Thanks for the reply, here is the Actor class:

public class Actor {

public static void main( String args[] ) {

}

//

/* Attribute Declarations */

//

/**

*

*/

/**

* Indicates that the gender is unknown.

*/

public static final int UNKNOWN = 0;

/**

* Indicates a <em>male</em> person.

*/

public static final int MALE = 1;

/**

* Indicates a <em>female</em> person.

*/

public static final int FEMALE = 2;

/** Specifies the first name of the person.

*

*/

private String firstName;

/** Specifies the last name (sometimes refered to as 'surname')

* of the person.

*/

private String lastName;

/** Specifies the age of the person, in

* the number of years of age (whole number of years)

*/

private int age;

/** This attribute indicates whether the person is

* male or female.

*/

private int gender;

// TODO - add an attribute to store the film title

//

private String filmTitle;

//

/* Constructor Declarations */

//

/** Default Constructor: Creates an instance of Actor with

* no specified values - default values assigned, firstName ("N/A"), lastName ("N/A"), age (0) and gender (UNKNOWN) and a default value of film title ("-None Specified-").

*/

public Actor () {

firstName = "N/A";

lastName = "N/A";

age = 0;

gender = UNKNOWN;

// TODO - Add the default value for film title

filmTitle = "-None Specified-";

} // end of Actor default constructor

/**

* Creates an instance of Actor with specified values for the

* first name, last name, age and gender of that person, and a default value of film title ("-None Specified-").

*

* @param pFirstName is the first name of the person

* @param pLastName is the last name of the person

* @param pAge is the age of the person, a whole number of years

* @param pGender is a value that specifies whether the person is male

* or female.

* @param pFilmTitle is the film title for the actor

*/

public Actor (String pFirstName, String pLastName, int pAge,

int pGender, String pFilmTitle) {

// assign argument values to instance attributes

firstName = pFirstName;

lastName = pLastName;

age = pAge;

gender = pGender;

// TODO - Add the default value for film title

filmTitle = pFilmTitle;

} // end of construnctor Actor four parameters

/**

* Creates an instance of Actor with specified values for the

* first name, last name, age, gender and the title of the actor's

* latest film.

*

* @param pFirstName is the first name of the person

* @param pLastName is the last name of the person

* @param pAge is the age of the person, a whole number of years

* @param pGender is a value that specifies whether the person is male

* or female.

* @param pFilmTitle is the title of the actor's latest film

*

*/

// TODO - Add the 'five parameter constructor

// ****

//

/* Method Declarations */

//

/**

* This method returns the first name of the person.

*

* @return the first name

*/

public String getFirstName () {

return firstName;

} // end of method

/**

* This method returns the last name of the person.

*

* @return the last name

*/

public String getLastName () {

return lastName;

} // end of method

/**

* This method acquires the gender information in the form

* of a string.

*

* @return the textual description of the gender

*/

public String getGenderName () {

if ( gender == Actor.MALE ) {

return "male";

} else if ( gender == Actor.FEMALE ) {

return "female";

} else {

return "unknown";

}

} // end of method

/**

* This method simply returns the numerical representation of the

* gender of the person.

*

* @return gender value

*/

public int getGender () {

return gender;

} // end of method

/**

* Gets the age of the person as of their most recently passed birthday

*

* @return age in number of years

*/

public int getAge () {

return age;

} // end of method

// TODO - add the assessor (get) method for the actor's latest film's title

//

public String getFilmTitle () {

return filmTitle;

} // end of method

/**

* Sets the first name of the person

*

* @param pFirstName is the first name of the person

*/

public void setFirstName (String pFirstName) {

firstName = pFirstName;

} // end of method

/**

* Sets the last name of the person

*

* @param pLastName is the last name of the person

*/

public void setLastName (String pLastName) {

lastName = pLastName;

} // end of method

/**

* Sets the gender of the person

*

* @param pGender is the gender of the person

*/

public void setGender (int pGender) {

gender = pGender;

} // end of method

/**

* Sets the age of the person

*

* @param pAge is the age of the person, in years, at his/her most

* recent birthday.

*/

public void setAge (int pAge) {

age = pAge;

} // end of method

// TODO - add the mutator (set) method for the actor's latest film's title

//

public void setFilmTitle (String pFilmTitle) {

filmTitle = pFilmTitle;

}

// TODO - modify the toString method so that the title of the actor's

// latest film is output too - EXACTLY as shown in the Exercise webpage.

//

/**

*

Obtains a textual representation of the Actor object.

*

NOTE: The output is terminated by a blank line.

*

* @return string representation of this instance of Actor

*/

public String toString () {

return "FirstName: " + firstName + "\nLastName: " + lastName +

"\nAge: " + age + "\nGender: " + getGenderName () + "\nLatest Film: " + filmTitle + "\n\n<end>";

} // end of toString method

} // end of class Person

Message was edited by:

bmzr

bmzra at 2007-7-15 4:33:49 > top of Java-index,Developer Tools,Debugging and Profiling Tool APIs...
# 3

It looks to me like you have 2 constructors; one with no arguments, one with 5 arguments (even though your comment says it has 4 arguments).

You need to reconcile the difference between TestActor using a constructor with 4 arguments and the Actor class having a constructor with 5 arguments.

atmguya at 2007-7-15 4:33:49 > top of Java-index,Developer Tools,Debugging and Profiling Tool APIs...
# 4

Hey I saw ur posting and ur code also. The problem with ur programme is that u r trying to instantiate an object of a class Actor which contains main() method with it and here the problem lies.

U can't make bject of such class.

Delete the main method in ur Actor class and then try to run ur programme . I think it must not show any errror than.

Thanx..

From

MAMNOON

invincibleBoona at 2007-7-15 4:33:49 > top of Java-index,Developer Tools,Debugging and Profiling Tool APIs...
# 5

> Hey I saw ur posting and ur code also. The problem

> with ur programme is that u r trying to instantiate

> an object of a class Actor which contains main()

> method with it and here the problem lies.

> U can't make bject of such class.

> Delete the main method in ur Actor class and then try

> to run ur programme . I think it must not show any

> errror than.

You can have a main method in every object. It will not stop you from creating an instance of it.

zadoka at 2007-7-15 4:33:49 > top of Java-index,Developer Tools,Debugging and Profiling Tool APIs...