class ShuZu
{
public static void main(String[] args)
{
int [] arr= new int []{1,3,2,4,34,53,54,23,};
System.out.println(printArr(arr));
}
public static void printArr(int [] arr)
{
for (int x=0;x<arr.length ;x++ )
{
if (x!=arr.length-1)
System.out.print(arr[x]+",");
else
System.out.println(arr[x]);
作者: 常佳杰 时间: 2012-6-18 10:21
哥们你是调用printArr()方法呢,
你是不是想直接打印arr数组? 要是就别用个这个方法了直接用方法里的循环语句
如:
class ShuZu
{
public static void main(String[] args)
{
int [] arr= new int []{1,3,2,4,34,53,54,23,};
for (int x=0;x<arr.length ;x++ )
{
if (x!=arr.length-1)
System.out.print(arr[x]+",");
else
System.out.println(arr[x]);
class ShuZu
{
public static void main(String[] args)
{
int [] arr= new int []{1,3,2,4,34,53,54,23,};
System.out.println(printArr(arr));
}
public static void printArr(int [] arr)
{
for (int x=0;x<arr.length ;x++ )
{
if (x!=arr.length-1)
System.out.print(arr[x]+",");
else
System.out.println(arr[x]);