This preview has intentionally blurred sections. Sign up to view the full version.View Full Document
Unformatted text preview: Two basic types: o Declarations o Executable statements Are terminated with ; Eg: double x = 3.5; import java.awt.Graphics; value = 3 * i; * System.out.println(“Hello”); //System is class, out is object, println is method Assignment Statements General form: variable = expression; The expression is evaluated and the result stored in the variable Eg: x = 5.3; y = x + 3.7; Expressions are a combination of operators and operands o They evaluate to some value Arithmetic Operators Operator Meaning + addition-subtraction * multiplication / division % modulus (remainder) • Division o If both operands are integers, the result is an integer (possibly truncated) Eg: 23 / 10 results in 2 o If one or more operands are floating point, the result is floating point Eg: 23.0 / 10 results in 2.3 • Modulus o 23 % 10 results in 3 o 23.0%10 results in 3.0 o-23.0 % 10 results in -3.0...
View Full Document
This note was uploaded on 11/04/2010 for the course CPSC 233 taught by Professor Li during the Fall '09 term at University of Calgary.
- Fall '09