When you have to pass an array to a method, you can directly pass the values without creating the array

If you have to pass an array to the method myMethod you would usually do something similar to this:

[] myArray = new int [3] {23, 48, 96, 114};

But why create an array when you can pass the integers directly? The compiler takes care to pack the integers into an array.

myClass.myMethod(23, 48, 96, 114);

Leave a Reply

Your email address will not be published. Required fields are marked *

Back To Top