CJCoding With Joseph

Generic Method (Parametric Polymorphism)

Generics let one method work with ANY type. Write a generic method Identity<T> in the Util class that takes a value of type T and returns it unchanged. The same method then works for int, string, or anything else. Do NOT write a Main method.

The tester calls it with an int and a string, so the program prints:
42
hi

Expected Output:

42
hi
Topics:
Polymorphism
Code Editor
1
Tab to indent ยท Ctrl+Enter to run ยท Ctrl+Space to expand shortcuts (cw, cr, fori)

Your Output

Run your code to see the output here...

Test Cases

Run your code to see test case results.