Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

what is the difference in E and T?

 
Raju Champaklal
Ranch Hand
Posts: 521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
am really confused in this part that is given in k&b....E is an element and T is a type that is not a collection? can anyone explain this to me?
 
Ankit Garg
Sheriff
Posts: 9521
22
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Using E to represent elements and T for type is just a convention. You are not forced to follow it...
 
Phungsuk Wangdu
Ranch Hand
Posts: 114
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
well you can use any other identifier if you wish to in place of E & T
 
Raju Champaklal
Ranch Hand
Posts: 521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
and why cant we use this?
 
Henry Wong
author
Marshal
Pie
Posts: 21220
81
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Raju Champaklal wrote:and why cant we use this?


Assuming that it was allowed, what is it supposed to do?


Or to ask it another way, wildcards are used to declare references so that it can point to generic objects of various different type. For the actual generic object, what is supposed to happen? What is a wildcard generic object, assuming there is such a thing, supposed to do?

Henry
 
Raju Champaklal
Ranch Hand
Posts: 521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
just what T did before...replace all T with whatever came in....
 
Henry Wong
author
Marshal
Pie
Posts: 21220
81
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Raju Champaklal wrote:just what T did before...replace all T with whatever came in....



Yea, so what does replacing all "?" with whatever came in supposed to do? It isn't exactly behaving as a wildcard. You are asking for the "?" to be a valid type?

Henry
 
Raju Champaklal
Ranch Hand
Posts: 521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
well doesnt ? mean accept anything that comes inside...and T means replace all T with the thing that comes in....
 
Henry Wong
author
Marshal
Pie
Posts: 21220
81
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Raju Champaklal wrote:well doesnt ? mean accept anything that comes inside...


No. A wildcard is used to declare a reference to a generic object, where the type T is not known.

Henry

 
Raju Champaklal
Ranch Hand
Posts: 521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
oh yaa....thanks for the clear definition of ? and what about T ? T is not known...means...even ? means doesnt know ...right?

 
Raju Champaklal
Ranch Hand
Posts: 521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the book says that E/T is a placeholder of the type you pass in...means ? cant be used in such a case....now its clear
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic