Java Logic Gates