java - Generic argument 'extends' multiple classes -


i have question generic arguments, code have:

public <t extends renderable, box> void setbackbox(t bb) {     ... } 

as see can give parameter bb object extends box & renderable. eclipse gives following waring: 'the type parameter box hiding type box'.

how can fix this/work around it?

here, you're defining 2 type-parameters:

  • t extends renderable
  • box

box alias of second method-scoped type-parameter , if have 1 same name (class-scoped), method-scoped 1 hide it. that's why eclipse throws warning.

if want t extend both renderable , box, have do:

public <t extends renderable & box> void setbackbox(t bb) 

also note when type-parameter(s) extend multiple types, you're allowed use one class, has first in list. example, if box class, correct definition be:

public <t extends box & renderable> void setbackbox(t bb) 

Comments

Popular posts from this blog

javascript - Google App Script ContentService downloadAsFile not working -

javascript - Function overwritting -

c# - Exception when attempting to modify Dictionary -