Remove last separator from print statement

前端 未结 6 689
情深已故
情深已故 2021-01-26 09:34

Here\'s a method for sorting an integer array. How can I remove the last separator form the output?

public void Sort(int[] sort) {
        for (int a:sort) {
            


        
6条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-26 09:47

        public void Sort(int[] sort) {
         int i = 1;
         String str = Arrays.toString(sort);
    
         str = str.substring(i,str.length()-1);
         System.out.println(str);
    }
    

提交回复
热议问题