I can't call string methods on element and argument.
The UML diagram tells me that StartsWith class has a Generic TypeT>String. I read in an other post you need to implement it in this way <T extends String>.
I would like to substitute Object for T in the
method here public boolean predicate(Object element, Object argument) but the compiler throws at me thats not possible.
interface:
public interface Intaf<T> {
public boolean pres(T element, T argument);
}
class:
public class StartsWith <T extends String> implements Intaf {
@Override
public boolean pres(Object element, Object argument) {
String firstLetterElement = element.substring(0,1);
String firstLetterArgument = argument.substring(0,1);
return firstLetterElement.equals(firstLetterArgument);
}
}