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
- Fall '09
- String literal, Arithmetic Operators Operator, chars String literals