Asked • 04/26/19

Any way to declare an array in-line?

Let's say I have a method m() that takes an array of Strings as an argument. Is there a way I can just declare this array in-line when I make the call? I.e. instead of: String[] strs = {"blah", "hey", "yo"}; m(strs); Can I just replace this with one line, and avoid declaring a named variable that I'm never going to use?

1 Expert Answer

By:

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.