Getting java heap space error


#1

I am getting java heap space, Following is my code. plz help

public String multiple(int A) {
Queue q = new LinkedList();
q.add(“1”+ “,” + “0”);

    while(!q.isEmpty()){
        String[] temp = q.remove().split(",");
        int r = mod(temp[0],A,Integer.parseInt(temp[1]));
        if(r==0){
            return temp[0].toString();
        }
        q.add(temp[0] + "0" + "," + String.valueOf(r));
        q.add(temp[0] + "1" + "," + String.valueOf(r));
    }
    
    return  "";
}

private int mod(String temp,int A,int r){
        r = r*10 + (temp.charAt(temp.length()-1)-'0');
        r = r%A;
    return r;
}