InterviewSolution
| 1. |
Can You Give An Example Of A Generic Method? |
|
Answer» A generic type can be declared as part of method declaration as well. Then the generic type can be used anywhere in the method (return type, parameter type, LOCAL or block variable type). Consider the method below: static <X extends Number> X doSomething(X number){ Integer i = 5; A generic type can be declared as part of method declaration as well. Then the generic type can be used anywhere in the method (return type, parameter type, local or block variable type). Consider the method below: static <X extends Number> X doSomething(X number){ Integer i = 5; |
|