KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I am mainly a C# developer and I was teaching Data Structures to my friend and they use Java in their University and I saw such an expression in Java: void printCollection(Collection<?> c) { for (Object e : c) { System.out.println(e); } } I haven't seen such a thing in C# so I wonder what's the difference between Collection<T> and Collection<?> in Java? void printCollection(Collection<T> c) { for (Object e : c) { System.out.println(e); } } I think it could have been written in the way above too. The guy in the documentation was comparing Collection<Object> and Collection<T> though. Examples are taken from http://docs.oracle.com/javase/tutorial/extra/generics/wildcards.html
Tags (comma-separated)
Save Edits
Cancel