Trait + Send
I'm still learning java and I'm not sure why this isn't working. it seems like this shouldn't be enough code to have an error. as far as I can tell everything is as it should be. I declared my class and it asked for a constructor method. because it asked for a constructor I added a constructor and it still wants a constructor.
答案 0 :(得分:3)
it seems like this shouldn't be enough code to have an error.
Because you are attempting to implement the Comparable
interface, not having enough code is an error here. You must implement the INSERT INTO MyTable (FirstCol, SecondCol)
SELECT 'First', 1
UNION ALL
SELECT 'Second', 2
UNION ALL
SELECT 'Third', 3
UNION ALL
SELECT 'Fourth', 4
UNION ALL
SELECT 'Fifth', 5
method, or else you will get a compiler error. The bare minimum you must add is:
compareTo
Of course you will want to do the actual comparison and return an public int compareTo(Product other)
{
return 0;
}
less than 0, 0, or greater than 0, depending on if this int
compares less than, equal to, or greater than the Product
other
.
It doesn't make sense that "it" is asking for a constructor. You don't have to supply any constructor; Java will implicitly declare a no-argument, do-nothing default constructor if you don't supply one. The only error I see so far has to do with supplying a Product
method.