Difference between revisions of "Print Array"
From CompSciWiki
Line 18: | Line 18: | ||
|Solution=The solution... | |Solution=The solution... | ||
+ | <pre> | ||
+ | public static void printArray( int[] n ) | ||
+ | { | ||
+ | for( int i = 0; i < n.length; i++ ) | ||
+ | { | ||
+ | System.out.print( n[i] + "," ); | ||
+ | } | ||
+ | } | ||
+ | <pre> | ||
}} | }} |
Revision as of 12:31, 30 March 2010
{{1010PrAD|ProblemName=Print Array
|Problem= Write a method which will take an array of ints as a parameter.
The method should print the elements of the array, separated by a comma.
Example:
int[] n = {45,32,78,45,890,45,32};
printArray(n);
Output:45,32,78,890,45,32
|SideSection=
Taken from http://www.flickr.com/photos/daniello/565304023/
An image or By Students section
|Solution=The solution...
public static void printArray( int[] n ) { for( int i = 0; i < n.length; i++ ) { System.out.print( n[i] + "," ); } } <pre> }}