For this Question: We are given a string. Your task is to compress the consecutive letters of the string 

For example, given string is "AAACCCBBD", thus here
A's occurrence 3 times
C's occurrence 3 times
B's occurrence 2 times
D's occurrence 1 time
So after compressing string becomes "A3C3B2D1".The first line of input contains an integer T denoting the number of test cases. Each test case will have a string provided in the new line.

Constraints: 
1 <= T <= 10
1 <= sizeof(String) <= 10^6
All characters of String are upper case letters. (A-Z)

Sum of size of Strings over all testcases is <= 10^6For each testcase, in a new line, print the compressed string for each test case in a new line. Input:
2
AAACCCBBD
ABCD 

Output:
A3C3B2D1
A1B1C1D1, I have written this Solution Code: import java.io.*;
import java.util.*;



class Main {

	public static void compress(String str, int l){
		for (int i = 0; i < l; i++) {


            int count = 1;
            while (i < l - 1 && str.charAt(i) == str.charAt(i + 1)) {
                count++;
                i++;
            }


            System.out.print(str.charAt(i));
            System.out.print(count);
        }
		System.out.println();

	}

	public static void main (String[] args) throws IOException{
        BufferedReader rd = new BufferedReader(new InputStreamReader(System.in));
		int test = Integer.parseInt(rd.readLine());
		while(test-->0){
			String s = rd.readLine();
			int len = s.length();
			compress(s,len);
		}
	}
}, In this Programming Language: Java, Now tell me if this Code is compilable or not?