java - Passing Any Type As A Method Parameter -
this question has answer here:
- passing in “any” class type java method 3 answers
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
Post a Comment