How should I change the code so as to not get this warning : Raw use of parameterized class

Solution 1:

While you can still continue to use your code in production, it should be avoided.

They usually require casts and they aren't type safe. They are also less expressive, and they don't provide self-documentation in the same way as parameterized types

When Generics was introduced in JDK 1.5, raw types were retained only to maintain backwards compatibility with older Java versions.

Thanks, Robin