small query regarding generics

Hi,

I am trying to run a small Generics program in Eclipse. My problem is that when I try to compile the below program, i get the following warning message - "Type safety: The expression of type List needs unchecked conversion to conform to List<String>Demo.java"

The warning is showing at line 25 which is the setC() method.

When I change the setC() method as -

publicvoid setC(List<String> c){

this.list = c;

}

the warning disappears.

Can anyone tell mewhy am I not getting this warning for getC() method where again I am not using generic parameter for List return type of getC().

import java.util.Collection;

import java.util.List;

import java.util.ArrayList;

publicclass Demo{

List<String> c =new ArrayList<String>();

staticvoid iterate(Collection<String> c){

for (String s : c)

System.out.println(s);

}

publicstaticvoid main(String args[]){

List<String> l =new ArrayList<String>();

l.add("Ashsih");

l.add("Abrol");

iterate(l);

}

public List getC(){

return c;

}

publicvoid setC(List c){

this.c = c;

}

}

[2256 byte] By [ashish-abrola] at [2007-11-26 21:16:02]
# 1
You are assigning a List (variable c) to a List<String> (variable this.c). Hence the message. The return type of the method has nothing to do with the message.
DrClapa at 2007-7-10 2:54:37 > top of Java-index,Core,Core APIs...