Java Reference
In-Depth Information
Program 1.4 Boolean expressions and boolean variable assignments
class BooleanExpression {
public static void main ( String [
]
args )
boolean a= true ;
boolean b= false ;
boolean expr1=a || b;
boolean expr2=a&&b;
System . out . print ( "a||b=" );
System . out . println ( expr1 ) ;
System . out . print ( "a&&b=" );
System . out . println ( expr2 ) ;
}
}
Compiling and running this program, we get the following console output:
a||b=true
a&&b=false
Boolean expressions and their role in program workflows will be presented in
the next chapter.
1.3.2 Mathematical functions
In Java, mathematical functions including trigonometric sine and cosine
functions and constants are all encapsulated into the Math class. The most
usual funct ions 6 are summarized in the table below:
6 Refer to the on-line documentation at http://java.sun.com/j2se/1.4.2/docs/
api/java/lang/Math.html for complete description of the available set of
functions.
 
 
Search WWH ::




Custom Search