• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Generic Confusion

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
public static <E extends Number> List<? super E> process(List<E> num)

this is the method's signature.
i want to use method like this
//Insert cod here
output=process(input);

which pair i should put at //Insert code here so that my code compile? at least is should accept input and output?

ArrayList<Integer> input=null;
ArrayList<Integer> output=null;

ArrayList<Integer> input=null;
List<Integer> output=null;

a. ArrayList<Integer> input=null;
List<Number> output=null;

b. List<Number> input=null;
ArrayList<Integer> output=null;

c. List<Number> input=null;
List<Number> output=null;

d. List<Integer> input=null;
List<Integer> output=null;

e. ArrayList<> input=null;
ArrayList<> output=null;

the answer in My book (SCJP 310-055 by Kathy Sierra and Bert Bates)
is b,e,f
but practically when i tested the code none of copiled.
please help to get answere
 
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That's correct - it does not compile for any of the choices. Please see the K & B errata for the correction to the question.

K & B errata
[ September 16, 2006: Message edited by: Barry Gaunt ]
 
Prashant Kataria
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thnaks for help.
 
If you were a tree, what sort of tree would you be? This tiny ad is a poop beast.
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic