• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Whats the use for WildCards Upperbound

 
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello friends,

I have written a code which is as follows ,



here when we try to add ChildClass object to "list", at runtime it is not able to judge that wheather ChildClass is subclass of SubClass or if SubClass is supertype of ChildClass .

Now if i remove that line


and replace it with



Atleast the above code should work as list is referencing "arrayList" , but this also doesn't work

Now when i added the method



to class Practising_Generic

and than if i add the folowing line in main method of class Practising_Generic



this also not working


so my question is

WHATS THE USE OF UPPERBOUND WILD CARD,
and which are the scenarios where we can use it,
can anybody please give an example
 
Bartender
Posts: 4568
9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What do you mean "it doesn't work"? What were you expecting to happen? And what actually happened?

(See ItDoesntWorkIsUseless)
 
Rahul Shivsharan
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok i wont use that phrase,


But than my question is when should i use the upper bound wild card in Generics.

 
Matthew Brown
Bartender
Posts: 4568
9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It's not about not using that phrase. If you can tell us what you expected to happen, and what actually happened, it makes it much easier to work out what is going on and how best to explain it. Otherwise we can't do any better than point you at relevant articles such as this one (which might explain what you want to know).
 
The knights of nee want a shrubbery. And a tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic