Boolean type

To make code easier to read, we shall define a new type called Boolean. Simply, stated, we use true and false for the values of 1 and 0.

Example:

	Boolean found = true;
	while ( ! found )
		{
			//look for something
		}

Example:

	Boolean inOrder (ArrayList list);
	// If the array is sorted in ascending order
	// the function will return true, false otherwise
	{
		Boolean order = true;
		int n = list.size();
		for (int x = 1; x < n; x++)
			if (list.get(x - 1) > list.get(x))
				order = false;
		return order;
	{
to call the function,
	if ( ! inOrder (list) )
		sort (list);


Continue to:  Unit 1  / Prev  / Next