Following code is throwing compile time exception
Type mismatch: cannot convert from Integer to K
What I understand is K
should handle any value that extends Number
.
public <K extends Number> K getValue(){
Integer a = new Integer(1);
return a;//Type mismatch: cannot convert from Integer to K
}
(Note: This is just a test code to put my question without giving irrelevant details of my actual scenario.)