As Campbell says, don't use raw types. That advice isn't limited to variable declarations, but also generic parameter declarations. In your declaration of
T, you're using
Membre as a raw type.
Let's break down what you're trying to do. From the code, it appears that you want to take a list of Membres, apply each Membre's action to s, and add the result to a new list.
It's clear that your code is not going to work, because you're casting the result of applying the action to T, which is almost certainly wrong. T is likely not the return type of the action method. The compiler would have told you about this if you hadn't used a raw type.
Instead, I assume this is what you want to do:
There are a few changes I made:
Renamed the classes, methods and variables so they are more easy to read.Declared X and Y (or you could declare S and R), because you can't use them before you declare them.Removed the T declaration, because you can declare all your variables in terms of X and Y.Changed the type of the input list to Iterable. Don't use more specific types than you need.Added upper and lower bounds to the functions variable, so the method can be used in a wider range of situations.Removed the cast. Combining casts and generics is a sign of badly written code.Used the diamond operator in the list creation.
If you're using
Java 8 or higher, you can also replace the method body with functional code: