generics - Java wildcard versus Object in API -


i have existing java api method:

public foo(collection<object> collection) {... } 

items read collection param, never updated. want change method to:

public foo(collection<?> collection) {... } 

is change guaranteed transparent, safe, , without side effects users?

note: not sure if important, api contains method:

public foo(object object) { ... } 

having parameter collection<?> allows users pass whatever collection want method, because collection<?> super type of types of collections.

in meantime, collection<object> compatible collection<object> values only, not collection<string>, collection<integer>, etc., makes difference between 2 approaches.

to summarize, applying change break method's initial intent, work collections of objects only.

the foo(object object) method method overload foo(collection<object> object) method , nothing more.


Comments

Popular posts from this blog

css - SVG using textPath a symbol not rendering in Firefox -

Java 8 + Maven Javadoc plugin: Error fetching URL -

datatable - Matlab struct computations -