Which of these is an correct way of defining generic method?

Khang Lê

New member
Which of these is an correct way of defining generic method?
A. name(T1, T2, …, Tn) { /* … */ }
B. public name { /* … */ }
C. class name[T1, T2, …, Tn] { /* … */ }
D. name{T1, T2, …, Tn} { /* … */ }
 
Answer: b
Explanation: The syntax for a generic method includes a type parameter, inside angle brackets, and appears before the method’s return type. For static generic methods, the type parameter section must appear before the method’s return type.
 

Tìm kiếm

Back
Top