Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Generics ....

 
kathir vel
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
  • 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 > ();
 
Prasad Tamirisa
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
  • 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.
 
mo shaik
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
kathir vel
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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'.
 
Manfred Klug
Ranch Hand
Posts: 377
  • Mark post as helpful
  • send pies
  • 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.
 
Priyam Srivastava
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
  • 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...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic