Notes
Outline
Introduction to the Java Language
Data Types
Operators
Control Flow Statements
Arrays
Functions -- Static Methods
View Classes as modules
Exampe1: Hello.java
Data Types
byte,short,int,long
float,double
char
boolean
reference
array
object
Operators
Arithmetic operators
+, -, *, /, %, ++, --
Relational operators
>, >=, <, <=, ==, !=
Conditional operators
&&,  ||,  !
Bitwise operators
>>, <<, >>>, &, |, ^, ~
Control Flow Statements
decision making
if-else, switch-case
loop
for, while, do-while
exception
try-catch-finally, throw
miscellaneous
break, continue, label: , return
Arrays
Dynamic
Anonymous array
a.length
Example 2: Max.java
Example 3: PrintArray
Functions -- Static Methods
Functions -- Static Methods
View Classes as Modules
View Classes as Modules
Review
Java language constructs
types
operators
control statements
arrays
View classes as modules of functions
static methods
View Classes as  Data Types (struct)
How to write functions that return multiple values
In C, use pointers
In Java, use objects
View Classes as Structures
Java
C
Difference between Objects and Structures
Java
Call by reference
actual argument is updated
C
Call by value
actual argument does not change
Functions That Return Multiple Values
Exercises
static Point center(Rectangle r)
return the center point of r.
static int area(Rectangle r)
return the area of r.
static boolean isCenter(Rectangle r, Point p)