I have created a method as bellow
static <N> N addTwoString(N a, N b){
StringBuilder sb = new StringBuilder();
sb.append(a);
sb.append(b);
return sb.toString();
}
public static void main(String[] args)
{
addTwoString("a", "b");
}
For this situation I pass two Strings and append that and return it using StringBuilder. Anyhow I am getting the error at return statement saying Type mismatch: cannot convert from String to N. My question here is this method accepts the String values (even the type is N) with out any issues but why it gives error at return statement?