Results 1 to 3 of 3
- 12-11-2012, 11:53 PM #1
Member
- Join Date
- Oct 2008
- Posts
- 45
- Rep Power
- 0
Type safety: The expression of type ... needs unchecked conversion to conform to ...
I have two classes: MakeMeHappy and ServeMe. ServeMe has a method that returns a List<Field>. But in MakeMeHappy, there is a warning that I don't understand how to get rid of (reported on line 11 of MakeMeHappy):
I'd like to know how to properly fix it so I am warning-free.Type safety: The expression of type List needs unchecked conversion to conform to List<Field>
Java Code:package barnacles; import java.util.ArrayList; import java.util.List; import net.sf.click.control.Field; public class ServeMe { private final List<Field> fields = new ArrayList<Field>(); public List<Field> getFields() { return this.fields; } }I'd prefer to avoid adding @SupressWarnings.Java Code:package barnacles; import java.util.List; import net.sf.click.control.Field; public class MakeMeHappy { public void doSomething() { ServeMe server = new ServeMe(); List<Field> fields = server.getFields(); // do stuff with the list } }
- 12-12-2012, 03:18 AM #2
Re: Type safety: The expression of type ... needs unchecked conversion to conform to
That's not a compiler message. Is it a warning from your IDE? Also, is this ite actual and complete code that produces that warning, or have you removed some stuff to make it shorter for posting on a forum?
I didn't see anything there that should generate a 'unchecked conversion' warning, so just to be sure, I created a similar code that doesn't depend on any non-JDK classes, and it compiles without warnings.
Try compiling from the command line.
dbWhy do they call it rush hour when nothing moves? - Robin Williams
- 12-21-2012, 04:32 AM #3
Member
- Join Date
- Dec 2012
- Posts
- 74
- Rep Power
- 0
Re: Type safety: The expression of type ... needs unchecked conversion to conform to
I copied and pasted your code into Eclipse. I didn't have the Field class so I made one up. The only warning that I got is that fields isn't used.
Will you post whole whole files including the Field class and I'll try it again.
Similar Threads
-
is it possible to convert String type of value into integer using type conversion?
By chandrasekhar.melam in forum New To JavaReplies: 6Last Post: 09-14-2012, 12:33 PM -
java enum : type safety
By rsai in forum New To JavaReplies: 2Last Post: 07-05-2012, 03:45 AM -
Type Conversion Confusion
By lala in forum New To JavaReplies: 8Last Post: 01-07-2011, 08:59 AM -
Type conversion
By hannes in forum New To JavaReplies: 2Last Post: 12-18-2009, 11:29 AM -
runtime type conversion
By sardare in forum Advanced JavaReplies: 3Last Post: 08-18-2008, 08:51 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks