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

OpenCV OpenCL: Convert Mat to Bitmap in JNI Layer for Android -

android - org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope -

python - How to remove the Xframe Options header in django? -