Exercise · Strings · lesson 11 of 11
Exercise: run-length encoding
Write a method static String compress(String s) that replaces each run of identical characters in a row with the character followed by the run's length.
compress("aaabcc")→"a3b1c2"compress("abc")→"a1b1c1"compress("")→""
Constraints: an uppercase and a lowercase letter are different characters; a run may be longer than 9 characters, and then its length takes several digits; a character that appears in several places gives several runs; an empty string gives an empty string.
Do not add extra imports unless the task says so explicitly.