关于字符数组越界,为什么越界了?!

为什么最后那段数组越界了?真的搞不明白,数组长度没有超标吧
import java.util.Scanner;
public class oj1600 {

public static void main(String[] args) {
    // TODO Auto-generated method stub
    Scanner sc=new Scanner(System.in);
    while(sc.hasNext()){
        
        int n=sc.nextInt();
        for(int i=0;iint t=0;
            int a=sc.nextInt();
            char c2[]=new char[a]; 
            String s=sc.next();
            c2=s.toCharArray();
    
            //记录0的个数
            for(int h=0;hif(c2[h]=='0'){
                    t++;
                }
            }
        
            //相同的变为0
            int t1=0;
            for(int j=0;j-1;j++){
                
                for(int x=j+1;xif(c2[j]==c2[x]){
                        c2[x]='0';
                        t1++;
                    }
                    //排序数字字符大小
                    if(c2[j]char f=c2[j];
                             c2[j]=c2[x];
                             c2[x]=f;
                    }
                }
            }
            
            int t3=0;
            int t4=a-t1+t;
            char c1[]=new char[t4];
            
            for(int b=0;bif(c2[b]!='0'){
                    c1[t3]=c2[b];
                    t3++;
                }
            } 
            String s1=String.valueOf(c1);
            System.out.println(s1);
        }
        
    }
}

}

img

c1的数组越界了,t3> t4了,你自己打印一下就能看出来了。
你的c1数组大小定义的长度为t4