java - Function to convert single objects to an array? -


I wanted to write a function that would take an object and change an object in that orgent that contains an element Will be included as. It has happened to me that I can do this generally and with common arguments that it does this automatically without the need to type the function for each object type, which I wanted to use would this code work? Should anybody know me well?

  public stable  

This works but it looks like:

  object o = new object (); Some method (new object [] {o});  

is a bit more straightforward:

  object o = new object (); SomeMethod (convert_to_array (o));  

In cases where sometimes I want to pass an object, but for the second time I want to exceed an array, generally I use the overloaded method in the API :

  Nullify the public (object o) {something (new object [] {o}); } Public zero doSomething (object [] array) {// stuff goes here}  

Verge can be used, but only if the array is the last parameter of the course.


Comments