Java implementation of A1