added java implementation of calculatestring