Win a copy of Escape Velocity: Better Metrics for Agile Teams this week in the Agile and Other Processes forum!
    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 ...
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Paul Clapham
  • Jeanne Boyarsky
  • Ron McLeod
  • Frank Carver
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
  • Piet Souris
  • Frits Walraven
  • fred rosenberger

doubt generics

Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Hi , can any one explain this code , this is from generics from k& b book

public class Test
static void addandDisp(List list)
for(Object e:list)
System.out.print(e.getClass()+" ");
public static void main(String[] args)
List<String> ls = new ArrayList<String>();

What will be the output?

a)Prints class java.lang.String class java.lang.long class java.lang.Double
b)Prints class java.lang.String class java.lang.Integer class java.lang.Double
c)Prints class java.lang.String class java.lang.Double class java.lang.Float
d)Compile time Error
e)Run time Error
CLUCK LIKE A CHICKEN! Now look at this tiny ad:
the value of filler advertising in 2021
    Bookmark Topic Watch Topic
  • New Topic