I have this method that complains to jdk1.6 (without warning of an error) about parameterization of a generic type is not used in Map and ...:
public static Font getStrikethroughFont(String name, int properties, int size) { Font font = new Font(name, properties, size); Map attributes = font.getAttributes(); attributes.put(TextAttribute.STRIKETHROUGH, TextAttribute.STRIKETHROUGH_ON); Font newFont = new Font(attributes); return newFont; }
Then I changed to the following:
public static Font getStrikethroughFont2(String name, int properties, int size) { Font font = new Font(name, properties, size); Map<TextAttribute, ?> attributes = font.getAttributes(); attributes.put(TextAttribute.STRIKETHROUGH, TextAttribute.STRIKETHROUGH_ON); Font newFont = new Font(attributes); return newFont; }
but
attributes.put(TextAttribute.STRIKETHROUGH, TextAttribute.STRIKETHROUGH_ON);
not valid.
TextAttribute.STRIKETHROUGH_ON is a boolean.
How can I use the Generic Type function in the method described above? I looked at the Core Java book, but could not find an answer. Can anybody help me?
source share