aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes what is the difference in E and T? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "what is the difference in E and T? " Watch "what is the difference in E and T? " New topic
Author

what is the difference in E and T?

Raju Champaklal
Ranch Hand

Joined: Dec 10, 2009
Posts: 521
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?


scjp 1.6 91%, preparing for scmad
"Time to get MAD now.. we will get even later"....by someone unknown
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9321
    
  17

Using E to represent elements and T for type is just a convention. You are not forced to follow it...


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Phungsuk Wangdu
Ranch Hand

Joined: Nov 04, 2009
Posts: 114
well you can use any other identifier if you wish to in place of E & T
Raju Champaklal
Ranch Hand

Joined: Dec 10, 2009
Posts: 521
and why cant we use this?
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 19061
    
  40

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


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Raju Champaklal
Ranch Hand

Joined: Dec 10, 2009
Posts: 521
just what T did before...replace all T with whatever came in....
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 19061
    
  40

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

Joined: Dec 10, 2009
Posts: 521
well doesnt ? mean accept anything that comes inside...and T means replace all T with the thing that comes in....
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 19061
    
  40

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

Joined: Dec 10, 2009
Posts: 521
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

Joined: Dec 10, 2009
Posts: 521
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
 
 
subject: what is the difference in E and T?