How about this approach (in terms of time&space complexity)?

static void first_non_rep(char a[]){

    LinkedList<Character>l=new LinkedList<>();
    for(int i=0;i<a.length;i++){
        l.addLast(a[i]);

        if(l.getLast()==l.getFirst()){
            while(l.size()>1 && l.getFirst()==l.getLast()){
                l.removeFirst();
                l.removeLast();
            }
        }

        if(l.isEmpty()){
            System.out.print("-1 ");
        }
        else{
            System.out.print(l.getFirst()+" ");
        }
    }
}

@magnus2001,
The time complexity is very high if you use LinkedList. A hashmap is the most efficient way for this question