These store the values true or false. There are two in the example below.
The first is called one_greater_than_two and stores the value obtained by evaluating the condition 1 > 2, which is clearly false.
The second is called two_greater_than_one and stores the value obtained by evaluating the condition 2 > 1, which is clearly true.
UBUNTU > cat prog20.java
public class prog20
{
public static void main (String args[])
{
boolean one_greater_than_two = (1 > 2);
boolean two_greater_than_one = (2 > 1);
if (one_greater_than_two)
{System.out.println ("1 > 2");}
if (two_greater_than_one)
{System.out.println ("2 > 1");}
}
}
UBUNTU > javac prog20.java
UBUNTU > java prog20
2 > 1
UBUNTU >
public class prog20
{
public static void main (String args[])
{
boolean one_greater_than_two = (1 > 2);
boolean two_greater_than_one = (2 > 1);
if (one_greater_than_two)
{System.out.println ("1 > 2");}
if (two_greater_than_one)
{System.out.println ("2 > 1");}
}
}
UBUNTU > javac prog20.java
UBUNTU > java prog20
2 > 1
UBUNTU >
If you have a
Java book on Amazon, which you would like to advertise here for free,
please write to me at international_dba@yahoo.co.uk.