Java programming trap