I have a problem, because SuppressWarning("unchecked") doesnt work.
package com.example;
import javax.swing.*;
import java.awt.*;
import java.io.IOException;
import java.util.Dictionary;
import java.util.Hashtable;
public class Main {
@SuppressWarnings("unchecked")
public static void test(Dictionary test) {
System.out.println(test);
}
public static void main(String[] args) throws IOException {
Dictionary<Integer, Component> labelTable = new Hashtable<>();
labelTable.put(1, new JLabel("text"));
labelTable.put(2, new JLabel("text 2"));
JSlider slider = new JSlider();
slider.setLabelTable(labelTable);
@SuppressWarnings("unchecked")
Dictionary<Integer, Component> labelTable2 = slider.getLabelTable();
}
}
shows this:
javac -Xlint com/example/Main.java
com/example/Main.java:14: warning: [rawtypes] found raw type: Dictionary
public static void test(Dictionary test) {
^
missing type arguments for generic class Dictionary<K,V>
where K,V are type-variables:
K extends Object declared in class Dictionary
V extends Object declared in class Dictionary
1 warning
Why it showed this warning after I had used @SuppressWarnings("unchecked")?
@SuppressWarnings("unchecked")
Dictionary<Integer, Component> labelTable2 = slider.getLabelTable();
This works..