|
-
January 23rd, 2003, 12:37 PM
#1
a simple Java question
Hello All,
I am a Java beginner, I met those problems:
1. I changed the name of the method multiply to multiply1
in the interface ICalc,when i compile the Calculaor.java,
error occured:
---------------------------------------------------------------------------------
edu\wpi\cs\cs509\calculator\Calculator.java:11: edu
ulator should be declared abstract; it does not def
wpi.cs.cs509.calculator.Calculator
public class Calculator implements IBlock, ICalc {
^
1 error
-----------------------------------------------------------------------------------
when I add "abstract" before class Calculator implements IBlock, ICalc
it worked.why????
2. I added a new method named add(int a,int b) in the interface ICacl
then i compiled another component which has used the ICal interface,
such error occured:
edu\wpi\cs\cs509\tutorial\FirstTry.java:146: cannot resolve symbol
symbol : method add_number (int,int)
location: interface edu.wpi.cs.cs509.calculator.ICalc
int res = ourCalculator.add(i2, i3);
could you tell me how to resolve this problem/
thanks a lot.
wangnj
-
January 23rd, 2003, 01:30 PM
#2
1. Your should do a little reasearch on polymorphism. Basically the method multiply is probally declaried abstract in ICalc, which means that if you don't want an abstract class, you must overide that method.
2. The method add_number is probally being refered to somewhere in your code, but it doesn't exist.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|