// Collection of code snippets by Arne Vajhøj 
// (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
public class ArrayToSpecialString {
   public static String arr2str(int[] a) {
      StringBuffer sb = new StringBuffer("");
      int last = -1;
      for (int i = 0; i < a.length; i++) {
         if (i > 0) {
            sb.append(",");
         }
         if ((a[i] / 1000) != last) {
            sb.append(a[i] / 1000);
            sb.append(",");
            last = a[i] / 1000;
         }
         sb.append(a[i] % 1000);
      }
      return sb.toString();
   }

   public static void main(String[] args) {
      int[] ia = { 95520, 95201, 95201, 95302, 55432, 55874, 55987, 55123 };
      System.out.println(arr2str(ia));
   }
}
