01-11-2012, 02:21 PM
Course Review
Course.ppt (Size: 48 KB / Downloads: 20)
Java Basics
Developed initially as a microcontroller language
Portable, Robust, Secure, Simple, OOP
Network Savvy,
Embedded Programs & Client-Server
Identifiers
Must start with a letter, underscore, or $ sign
May have any number of letters, digits, $ sign, or underscores
Used to name classes, objects, methods, & packages
Java Primitives
Eight Primitive Types
byte, short, int, long,
float, double,
char,
boolean
When we define (declare) primitives
We automatically reserve storage space
Not so with arrays & objects
Automatically initialized to zero
unless we initialize it to something else
Variables must belong to a class or method
Java Methods
This is where the 'code' lives
The instructions to carry out the tasks
The actions of our objects
They are named in accordance with the identifier rules
Invoking a method is a request to the object to do something
When a method has a return type it may be used as an expression
Java Method Return Types
Java methods must have a return type specified
it may be void
it may be a primitive
it may be an array
it may be an object based on any valid class
In the case of the class we may
create a 'new' object
or return a reference to an existing object
or return null
Java Method Signatures
The signature of a method is its
types of the arguments
the order of the types of the arguments
number of arguments
This can be determined at run-time
This is what allows run-time polymorphism
Defining Classes
When we define a class
we give the class a name
we identify any inherited features
extends or implements
we may restrict its features which may be inherited
abstract or final
we identify the state information
we identify the actions
This does not
create an object
set memory aside
Arrays
Something between primitives & Objects
Named group of objects or primitives of the same type
Members of the group are distinguished by their position
Arrays always know their size
arrayIdentifier.length
When referring to entire arrays we omit the square brackets