| Author |
Error : class not found
|
Aryan Jain
Greenhorn
Joined: Mar 01, 2012
Posts: 4
|
|
Hii...
I am getting class not found error while executing a program.
List of files
ClassMain.java
Manager.java,Clerk.java,SalesPerson.java,Employee.java these 4 classes extends CompanyEmployee.java
In ClassMain.java
i have created a subclass object using superclass reference like this
CompanyEmployee employeeTwo = new Manager();
employeeTwo.setAllowance(1000);
setAllowance is a method in Manager.java
while compiling i am getting
error cannot find symbol
employeeTwo.setAllowance(1000);
I have checked spelling of functions in both the files but their is no mistake.
So,please reply me.
Thanks in advance.
|
 |
Rob Spoor
Sheriff
Joined: Oct 27, 2005
Posts: 19216
|
|
Welcome to the Ranch!
Why do you think the problem is a class not found? From that error message, I see two possibilities:
1) employeeTwo does not exist (but that's not the case, you just declared it).
2) class CompanyEmployee does not have a method setAllowance that takes an int, long, float or double (and this must be the case).
Which class defined method setAllowance? If that's Manager, then you need to declare employeeTwo as Manager to be able to call that method.
|
SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
|
 |
Aryan Jain
Greenhorn
Joined: Mar 01, 2012
Posts: 4
|
|
Thanks for your quick response.
i have declared ProjectAllowance in Manager class which extends CompanyEmployee class
|
 |
Rob Spoor
Sheriff
Joined: Oct 27, 2005
Posts: 19216
|
|
|
But method CompanyEmployee does not have that method, you so you can't use a variable of that type to call it.
|
 |
Aryan Jain
Greenhorn
Joined: Mar 01, 2012
Posts: 4
|
|
Thank you....
|
 |
Rob Spoor
Sheriff
Joined: Oct 27, 2005
Posts: 19216
|
|
|
You're welcome.
|
 |
 |
|
|
subject: Error : class not found
|
|
|