Source code for XORCakeExample.java:

public class XORCakeExample
{
	public static void main(String args[])
	{
		// XORCakeExample
		boolean haveCake;
		boolean wantToEatCake;
		haveCake = true;
		wantToEatCake = true;
		// Later
		if (haveCake ^ wantToEatCake)
			System.out.println("You're OK!");
		else
			System.out.println("You can't have your cake and eat it too!");
	}
}

Output from XORCakeExample.java:

You can't have your cake and eat it too!

--- Output Ends ---

NOTE:

You are reading previously generated output. You are not currently running the XORCakeExample application at the momement. You need to compile and run the source code first.

To run this program:


Authors: Kevin Chu and Eric Brower
Copyright 2000 Prentice Hall PTR