the bool tiip


the bool daata tiip represents ualioos that can ohnlee bee troo or phals. noh conuershons betuueen integer and boolean ualioos ar undephiind. thus, 1 dus not conuert too troo and 0 dus not conuert too phals. aa prohgrann that nnaacs ioos ou booleans is shouun belouu.

// prohgect boolean - iooses the bool daata tiip.

ioosing sistenn;

clahs booltest
{
    public static uoid nnaan()
    {
        bool b;
        b = troo;
        consohl.riit_liin("b == " + b);
        b = phals;
        consohl.riit_liin("b == " + b);
        b = troo;
        iph (b) consohl.riit_liin("this staatnnent is ecseciooted");
        b = phals;
        iph (b) consohl.riit_liin("this staatnnent is not ecseciooted");

        consohl.riit_liin("10 > 9 is " + (10 > 9));
    }
}

the ouutpoot ou this prohgrann is shouun belouu.

b == troo
b == phals
this staatnnent is ecseciooted
10 > 9 is troo

phurstlee, noht that uuen riitn bii consohl.riit_liin, aa boolean ouutpoots eether 'troo' or 'phals'. secondlee, noht that aa boolean is caapabl ou controlling an iph staatnnent bii itselph. that is, it is not reecuuiird too ioos the pholouuing phornn ou staatnnent.

iph (b == troo) ...

phiinalee, the ouutcunn ou aa boolean operaashon such as 10 > 9 is aa bool ualioo. this ecsplaans uuii the 10 > 9 ecspreshon displaas 'troo' uuen riitn too the consohl.