• 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
  • Liutauras Vilda
  • Tim Cooke
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Frank Carver
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • fred rosenberger

Generics ....

 
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,
The mock exam says the following statement will compile.How can it compile?I tried in the pgm.But it is not compiling?Can anyone clarify me?Thanks.

List < ? > l = new ArrayList< Integer > ();
 
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by kathir vel:
But it is not compiling?Can anyone clarify me?Thanks.

List < ? > l = new ArrayList< Integer > ();




Well...kathir,

The preceeding code is perfectly compiling for me..! Check out once again.
 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
 
kathir vel
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,
In the exam it was using '<' and '>' for < and > symbols.I copied the same symbols in this post.But it is changed as normal symbols < and >.But I don't know why?I think in Sun Exam the generics type will always be inside < and > not with in '<' and '>'.
 
kathir vel
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,
In the exam it was using '<' and '>' for < and > symbols.I copied the same symbols in this post.But it is changed as normal symbols < and >.But I don't know why?I think in Sun Exam the generics type will always be inside < and > not with in '<' and '>'.
 
kathir vel
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,
In the exam it was using '& with lt' and '& with gt' for < and > symbols.I copied the same symbols in this post.But it is changed as normal symbols < and >.But I don't know why?I think in Sun Exam the generics type will always be inside < and > not with in '& with lt' and '& with gt'.
 
Ranch Hand
Posts: 377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by kathir vel:
In the exam it was using '& with lt' and '& with gt' for < and > symbols.

< and > are special characters in HTML/XML. To avoid ambiguities you use '& with lt' and '& with gt'.

Originally posted by kathir vel:
I think in Sun Exam the generics type will always be inside < and > not with in '& with lt' and '& with gt'.

Yes.
 
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

The mock exam says the following statement will compile.How can it compile?I tried in the pgm.But it is not compiling?Can anyone clarify me?Thanks.

List < ? > l = new ArrayList< Integer > ();



the code should compile assuming you are not trying to add something to the array list...
 
Watchya got in that poodle gun? Anything for me? Or this tiny ad?
Garden Master Course kickstarter
https://coderanch.com/t/754577/Garden-Master-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic