"ste1986" <steiddon_1@hotmail.com> said:
>im getting the error message "Incompatible types - found Volunteer but
>expected java.lang.String" why is this. the error occurs in the
[quoted text clipped - 3 lines]
>{
> // instance variables
...
> public String volunteer;
Here you define that the Person class has a field with name volunteer
(and of type String).
...
> public void assignPerson(Volunteer volunteer)
> {
> withVolunteer = true;
> this.volunteer = volunteer; //ERROR
> }
And here you have a method with parameter of type Volunteer (named
volunteer), which you're trying to assign to the field of type String.
Apparently Volunteer is not a subclass of String (and how could it, as
java.lang.String is "final" - i.e. subclassing of it is not allowed.
To fix, either change also the field to type Volunteer, or the method
parameter to type String (whichever suits better to your intended uses).

Signature
Wolf a.k.a. Juha Laiho Espoo, Finland
(GC 3.0) GIT d- s+: a C++ ULSH++++$ P++@ L+++ E- W+$@ N++ !K w !O !M V
PS(+) PE Y+ PGP(+) t- 5 !X R !tv b+ !DI D G e+ h---- r+++ y++++
"...cancel my subscription to the resurrection!" (Jim Morrison)
> im getting the error message "Incompatible types - found Volunteer but
> expected java.lang.String" why is this. the error occurs in the
[quoted text clipped - 10 lines]
> this.volunteer = volunteer; //ERROR
> }
Because you have assigned an expression of type Volunteer (the local
variable, volunteer) to a variable of type String (the member variable,
volunteer).
Tom Hawtin

Signature
Unemployed English Java programmer
http://jroller.com/page/tackline/