Home arrow static arrow Java Programming [Archive] - creating arrays in method argument
Warning: Creating default object from empty value in /www/htdocs/w008deb8/wiki/components/com_staticxt/staticxt.php on line 51
Java Programming [Archive] - creating arrays in method argument
This topic has 1 reply on 1 page.

Posts:28
Registered: 3/30/03
creating arrays in method argument  
Aug 8, 2004 7:54 AM



 
this words fine
int[] f = {1,2,3,4};


but when i try make it into one line, for example for usage as arguments to a method, it does not compile

class test { 	public static void a(int[] in) {}public static void main (String[] args) { 		a( (int[]) {1,2,3,4 } );	}};


i know i could just declare the array before hand, but it in my case it involves calling a super constructor, which must be the first line in the function.

help would be appreicated
 

Posts:18,384
Registered: 21.03.00
Re: creating arrays in method argument  
Aug 8, 2004 7:56 AM (reply 1 of 1)



 
Hi,

a(new int[] { 1,2,3,4,});

/Kaj
 
This topic has 1 reply on 1 page.