Problem with interfaces
Hello, I'm having trouble implementing a class that uses a interface (known as Measurable).
Any help would be greatly appreciated as I am highly confused
My errors are:
cannot find symbol class Measurable
operator + cannot be applied to double, Measurable.getMeasure
and double cannot be dereferenced
my code is
public class DataSet
private double sum;
private int count;
private double maximum;
public void add(Measurable x)
sum = sum + x.getMeasure();
if (count == 1 || x.getMeasure()>maximum.getMeasure()) maximum=x;
public double getSum()
public int getCount()
public double getMaximum()
public double getAverage()
Fixed some stuff
actually scratch what I said earlier. New code with only one error cannot find symbol class Measurable. Any reason it can't find the class? (Measurable is the interface).
Extending an interface with inheritance : Interface and Abstract Class*«*Language Basics*«*Java
I believe you need to implement the interface:
Also, use code tags when posting code, [code] to open [ /code]
public class MyClass implements MyInterface
Where is Measureable?
Is it in a package?
How are you compiling this?