• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

Legacy Code to Generics  RSS feed

 
Ranch Hand
Posts: 244
  • 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: 21461
96
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.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!