Re: Perl Pro but Java Newbie: Need nudge in proper direction for
my favorite Perl routine in Java
Joshua Cranmer wrote:
Mark Space wrote:
Mark Space wrote:
void puts( Object ... o ) {}
void puts( int ... i ) {}
Also, I got to thinking about this, and tested it. I was wrong,
Object ... will allow primitives to be auto-boxed to objects:
Autoboxing is pretty smart, except for one (admittedly a bit edgy) case:
List<Integer> list = Arrays.asList('a');
or other cases where you would have to both convert and auto{un}box
(?5.3 doesn't allow both a widening primitive conversion and a
{un}boxing conversion for method invocation conversions).
That actually might be a good thing. Autoboxing would create two
objects here -- the array and the object -- just to pass one primitive.
It's probably a better idea just to create a method that takes a
single primitive and get the performance boost.
I wonder if autoboxing is smart enough to match things like
public static void testMethod( int i, int i2 ) {}
before it matches "Object... o"