• Post Reply Bookmark Topic Watch Topic
  • New Topic

Legacy Code to Generics  RSS feed

 
Ranch Hand
Posts: 243
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I have the following code.



Now if I make it to generic for 1.5 it becomes as below:


it is giving a warning : Type safety: Unchecked cast from Object to Vector<Stock>..As because clone() method returns Object that is why the warning arises...How to remove that warning?

Please suggest.

 
Sheriff
Posts: 21291
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Unless you can change the signatures of the methods all that remains is using @SuppressWarnings("unchecked"). you should be careful with that; any use of it should be as limited as possible (so if possible use it only with local variables) and well-documented why the cast is safe.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!