Generic Lists

View: New views
2 Messages — Rating Filter:   Alert me  

Generic Lists

by Patrick Lannigan-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I wrote a generic class Sample<T> that contains a Vector<T>, however I'm not sure how to tell the framework the object type in the vector. When I had used ElementList on a Vector<Abc> the framework would know that it was looking for Abc. But when I am trying to assign the type I get errors if I try type=T and type=T.class. Is there a way to tell the framework that it will be working with the generic object T?

Patrick

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Simple-support mailing list
Simple-support@...
https://lists.sourceforge.net/lists/listinfo/simple-support

Re: Generic Lists

by niall.gallagher :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,
 
You can blame Java here. Java does not have reified generics, so the type T is erased after compile time. So there is no way to get T for Vector<T>. Maybe in Java 7 they will addres reified generics.
 
Niall
 
Niall Gallagher
RBS Global Banking & Markets
Office: +44 7879498724

 


From: Patrick Lannigan [mailto:p.lannigan@...]
Sent: 27 August 2009 20:04
To: simple-support@...
Subject: [Simple-support] Generic Lists

I wrote a generic class Sample<T> that contains a Vector<T>, however I'm not sure how to tell the framework the object type in the vector. When I had used ElementList on a Vector<Abc> the framework would know that it was looking for Abc. But when I am trying to assign the type I get errors if I try type=T and type=T.class. Is there a way to tell the framework that it will be working with the generic object T?

Patrick
***********************************************************************************
The Royal Bank of Scotland plc. Registered in Scotland No 90312. Registered Office: 36 St Andrew Square, Edinburgh EH2 2YB. 
Authorised and regulated by the Financial Services Authority. 
 
This e-mail message is confidential and for use by the 
addressee only. If the message is received by anyone other 
than the addressee, please return the message to the sender 
by replying to it and then delete the message from your 
computer. Internet e-mails are not necessarily secure. The 
Royal Bank of Scotland plc does not accept responsibility for 
changes made to this message after it was sent. 

Whilst all reasonable care has been taken to avoid the 
transmission of viruses, it is the responsibility of the recipient to 
ensure that the onward transmission, opening or use of this 
message and any attachments will not adversely affect its 
systems or data. No responsibility is accepted by The 
Royal Bank of Scotland plc in this regard and the recipient should carry 
out such virus and other checks as it considers appropriate. 

Visit our website at www.rbs.com

***********************************************************************************

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Simple-support mailing list
Simple-support@...
https://lists.sourceforge.net/lists/listinfo/simple-support