Guest User

varargs fail with zero args

a guest
Feb 28th, 2012
24
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.util.Arrays;
  2.  
  3. public class MyArr {
  4.  
  5.     public static void main(String[] args) {
  6.         String[] works = array("working", "strings");
  7.         System.out.println(Arrays.toString(works));
  8.         String[] fails = array();
  9.         System.out.println(Arrays.toString(fails));
  10.     }
  11.  
  12.     public static <T> T[] array(T... args) {
  13.         return args;
  14.     }
  15. }
RAW Paste Data