Advertisement
JeffGrigg

Untitled

Jul 7th, 2019
938
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5 0.62 KB | None | 0 0
  1.     public static String asArray(String value) {
  2.         final StringBuilder output = new StringBuilder();
  3.         char a[] = (value + "\0").toCharArray();
  4.         int i, m, j;
  5.         for (i = 0; a[i] != '\0'; i++) {
  6.             m = 1;
  7.             for (j = 0; a[j] != '\0'; j++) {
  8.                 if (j >= i)
  9.                     if (a[j] == a[j + 1]) {
  10.                         m++;
  11.                     } else {
  12.                         break;
  13.                     }
  14.             }
  15.             output.append(String.valueOf(a[i])).append(m);
  16.             i = i + m - 1;
  17.         }
  18.         return output.toString();
  19.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement