i believe you have declared your list as a raw type, i.e.
List list = new List();
what you need to do is:
List<Integer> list = new List<Integer>();
or else you would have to typecast whenever you do list.get() like
sum=sum+(Integer)list.get(i);
EDIT: regarding your other problem
If i define like --> 'List list', seeing error suggestion
like "Syntax error, parameterized types are only available if source
level is 1.5"
Answer:
my guess would be that while you run eclipse itself with jdk 1.6, it's
actually configured with a different default jre. see
window->preferences->java->Installed JREs and make sure that the
checked JRE is 1.6. (i'm hoping that you are getting this error while
working in some IDE) if the default JRE is indeed 1.6, chances are
that it's a project specific setting. see that the project is
configured to use the right jre.