Re: What do these errors mean?
On 2/12/2012 9:07 AM, Lew wrote:
Knute Johnson wrote:
A B wrote:
I've finally got around to compiling my program with -Xlint, as the
compiler kept nagging me to. This is what I got. (I've removed some
entries for different bits that caused identical errors.) I haven't a
clue what any of it means or what to do about it; can anyone enlighten
me? What's a raw type, for instance, and what's a serializable class and
how do you give it a definition of serialVersionUID?
----------------------------------------------
Vectorine.java:39: warning: [rawtypes] found raw type: JComboBox
JComboBox droplist = new JComboBox();
^
missing type arguments for generic class JComboBox<E>
where E is a type-variable:
E extends Object declared in class JComboBox
...
I can tell you are using Java 7, JComboBox has changed to a generic
class. The simple answer is if you are creating a JComboBox of Strings,
declare it thus;
JComboBox<String> box = new JComboBox<String>(String[] items)
Or, since it's Java 7,
JComboBox<String> box = new JComboBox<>(items)
(The 'String[]' in an invocation is an error. It is useful to show a possible
type for the argument, but is not compilable as such. So, "A B", be sure to vet
any code before blindly copying and pasting. Usenet code posts are often, as
above, actually pseudocode.)
True, I pulled it from the Docs, and I did forget that you don't need to
specify the type on the right.
--
Knute Johnson