java - Passing Any Type As A Method Parameter -


this question has answer here:

i trying have method can take in type parameter (object, int, boolean, arraylist, etc.). here simple method illustrate trying do:

public void printanything(type arg0) {     system.out.println(arg0); } 

and asking is, replace type in method?

in specific example, object fit because printstream#println(object obj) print string representation (using string#valueof(object)).

when pass primitive value, automatically boxed wrapper type, e.g int converted java.lang.integer extends object.


Comments

Popular posts from this blog

java - Solr query version issue: Invalid version or the data in not in 'javabin' format -

Hard vs. Soft Water: What's The Difference?

The Ten Most Livable Cities In The World