#GENERIC HELP

20 messages · Page 1 of 1 (latest)

chrome beacon
#

public static <T> void copy(List<? super T> dst, List<? extends T> src)

viscid quarryBOT
#

This post has been reserved for your question.

Hey @chrome beacon! Please use /close or the Close Post button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.

TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.

chrome beacon
#

Collections.<Number>copy(objs, ints);

#

Why can I do this ?

#

assuming objs is a list of objects

#

and ints a list of integers

#

if we do Collections<Number>

#

it means in the method copy we should be able to put a list f something that is a parent or equal tot

#

and in the list something thats a child or equal to t

#

I dont see it how it works on this specific case i shared

#

nvmn

#

i sleepy

#

thats why i do this dumb mistakes

honest ledge
#

why should you not be able to do that?

#

numbers are objects after all

#

the first argument needs to be a list of any supertype of T (or T is allowed as well) and the second one needs to be a list of a subtype of T (or T itself)

chrome beacon
#

yeah ur right

#

i was just sleepy

#

i got some sleep now it should be fine