孤城少主
class Test{ public static void main(String[] args){ int [] arr = {23,12,45,25,36,45,}; //Demo d = new Demo(); //d.BianLi(arr); Demo.BianLi(arr);public class Demo{private Demo(){} //遍历数组 public static void BianLi(int [] arr){ System.out.println("["); for(int i =0;i<arr.length;i++){ if(i==arr.length-1){ System.out.print(arr[i]+"]"); }else{ System.out.print(arr[i]+", "); } } System.out.println(); }