I have very simple source file GuiApp1.java which I am trying to compile with cmd javac. It gives me warning that :
C:\Users\Thakkar\Java>javac GuiApp1.java
Note: GuiApp1.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
so I used cmd as javac -Xlint GuiApp1.java for compile the source file.
it gave me 6 warnings e.g.
GuiApp1.java:48: warning: [rawtypes] found raw type: JComboBox
JComboBox fruits = new JComboBox(fruitOptions);
^
missing type arguments for generic class JComboBox<E>
where E is a type-variable:
E extends Object declared in class JComboBox
how can i solve this?
Starting from Java 7 many Swing components use generics, so older code will produce a warning for raw types.
For the combobox example you can eliminate the warning if you provide the type of the objects it holds e.g. you should use JComboBox<String> fruits = new JComboBox<>(fruitOptions); if fruitOptions is a String[]. If you use some other type change it accordingly.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With