• Post Reply Bookmark Topic Watch Topic
  • New Topic

Generics in Java 5  RSS feed

 
Ludmila Snova
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am migrating java 1.4 application to 5.0 and I have a question. In our application we have a class SomeCollection that extends Vector. And that SomeCollection used everythere in the app to store different types of object.
As I understand correctly, with Java 5.0 vector should be parameterized. Is there any way to make it general? So I don't need to change every line in app? Or the only way to get rid of SomeCollection and use parameterized vector instead?

This is what I have now:


I tried this:

But it gives a compile error.

Thanks.
[ November 18, 2008: Message edited by: Ludmila Snova ]
 
Rob Spoor
Sheriff
Posts: 21135
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try Vector<Object>. It's the closest match to the situation as it is with Java 1.4 - you can put anything in it, and everything needs to be cast when retrieved.
 
Bill Shirley
Ranch Hand
Posts: 457
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As I understand correctly, with Java 5.0 vector should be parameterized.


I'd say it "could" be parameterized.
 
Rob Spoor
Sheriff
Posts: 21135
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Except if you don't parameterize it you will be flooded with warnings.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!