aspose file tools*
The moose likes Beginning Java and the fly likes Question on resolving generics Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Question on resolving generics" Watch "Question on resolving generics" New topic
Author

Question on resolving generics

Melinda Savoy
Ranch Hand

Joined: Jun 21, 2005
Posts: 386

I'm getting 2 warnings regarding generics that I cannot resolve. I'm running on Java 6 using Eclipse 3.2.2.

1st warning:

The argument of type String[] should explicitly be cast to Object[] for the invocation of the varargs method format(String, Object...) from type MessageFormat. It could alternatively be cast to Object for a varargs invocation

The warning refers to code in method writeExportLinks() (line 618):



2nd warning:

Type safety: The method put(Object, Object) belongs to the raw type Map. References to generic type Map<K,V> should be parameterized

The warning refers to code in method getOpenTag() (line 632):



ANY help or direction would be greatly appreciated.

Regards.
Bill Shirley
Ranch Hand

Joined: Nov 08, 2007
Posts: 457
I'm guessing



is wanted because of the vararg declaration of the method allows
write(String)
or
write(String, Object)
or
write(String, Object, Object)
ad infinitum

also, the declaration of the Map variable should be generically parameterized:


(on the assumption the map is String->String)
if attributeMap is also correctly declared, the clone method will return the correct type.


Bill Shirley - bshirley - frazerbilt.com
if (Posts < 30) you.read( JavaRanchFAQ);
Melinda Savoy
Ranch Hand

Joined: Jun 21, 2005
Posts: 386

Bill,

Thanks for the reply. I'll give it a shot.

Regards.
 
Consider Paul's rocket mass heater.
 
subject: Question on resolving generics
 
Similar Threads
Generics & explicit casting
Generics
Generics
Generics
Generics