Question : How to use generics  (Migrating from java 1.4.2 to 5.5)  properly?

Hi,

I am migrating few java standalone/web apps from version 1.4.2 to 5.0.
Migrating from WAS 5.1.2 to WAS 6.1
Using Rational Application Developer 7.

I get lots of warnings for using raw types (generics), for not using serialVersionUID, not using some declared
variables etc..

Should I use the generics? or should I use annotatations to ingore these warnings?
Which is better?

Thanks.
_Esam.

Answer : How to use generics  (Migrating from java 1.4.2 to 5.5)  properly?

There are 3 issues here:

1) warnings for using raw types (generics),
2) not using serialVersionUID,
3) not using some declared variables etc.

2) and 3) are not related to upgrading java versions. Simply you havent defined a SUID or your not using a declared variable in your code.

1) is related to generics and upgraidng from java 1.4 to 5.

The question was: Should I use the generics? or should I use annotatations to ingore these warnings?

well it depends on whether you want to ignore the warnigs or fix them.  The question itself doesnt make sense really, as its more of a case of how you want to deal with the warning rather than what way is better.

If you want to ignore warnings you can use an annotation to ignore warnigns related to generics (or other things as wlel) if you wish.

If you would actually like to get rid of the warnings properly you needs to find th ecases where they appear and impleent the use of generics properly in those cases.

There are many tutes on generic s on the web so not gonn aprovide a link but a lot of your issues will be with:

List l = new ArrayList();   <---- generic type not defined

needs to be more like:

List l - new ArrayList();

where T is the type of instance you will store in the lists.

Hope that points you in the right direction

Random Solutions  
 
programming4us programming4us