title: Java Equivalent of C# Anonymous Arrays and Lists?
body: <p>C# lets me make arrays on the fly when I need to pass them into functions. Let's say I have a method called <code>findMiddleItem(String[] items)</code>. In C#, I can write code like:</p>
  
  <pre><code>findMiddleItem(new String[] { "one", "two", "three" });
  </code></pre>
  
  <p>It's awesome, because it means I don't have to write:</p>
  
  <pre><code>IList&lt;String&gt; strings = new List&lt;String&gt;();
  strings.add("one");
  strings.add("two");
  strings.add("three");
  findMiddleItem(strings.ToArray());
  </code></pre>
  
  <p>Which sucks, because I don't really care about <code>strings</code> -- it's just a construct to let me pass a string array into a method that requires it. A method which I can't modify.</p>
  
  <p>So how do you do this in Java? I need to know this for array types (eg. String[]) but also generic types (eg. List).</p>