Richard's J2SE Day 1, Getting Started

=================================================================
Old notes from "Sams Teach Yourself Java 2 in 21 Days" (still vaild, but different page number)
=================================================================

(P11)
- Object-oriented programming
- Platform neutrality

Java is easier than C++, (P12)
- Java takes care of memory allocation / deallocation
- Java doesn't include pointers
- Java includes only single inheritance in OOP

Object-Oriented Programming
- Organise programs into classes
- Classes are used to create objects
- Define a class > 2 aspects > how it should behave + what its attributes are
- Connect classes, inherits
- Linking classes through packages and interfaces

Using Java Language > using Java 2 class library, keywords, operators

Class = attributes + behavior
-
Attribute of one particular object = Instance variable
- Attribute of an entire class = Class variable
-
Groups of related statements in a class of objects = Methods

(P20) VolcanoRobot.java
- *.class
- class keyword
- new keyword
- public static void main(String[] arguments) {}
- System.out.println();
Running the Program (P21)
- javac classname.java (javac VolcanoRobot.java) to create class file
- java classname (java VolcanoRobot) to "run" class file

Inheritance (P25)
- mechanise enables one class to inherit all the behavior and attributes of another class
Subclass - a class that inherits from another class
Superclass - a class that gives the inheritance
- A class can have only one superclass (single inheritance, C++ has multiple inheritance), each class can have a unlimited number of subclasses.
- At the top of the Java class hierarchy > class Object (default inheritance)
- A new object has access to all method names in its class and superclass. (check object's class first, then superclass). Overriding: create a method in a subclass that prevents a method in a superclass from being used.

Interfaces (P31)
- An interface is a collection of methods that indicate that a class has some behavior in addition to what it inherits from its superclass. (to duplicate similar behavior across different branches of a class hierarchy)

Packages (P31)
- Packages are a way of grouping related classes and interfaces.
- The class libraries in Java are combined in a package called java.
- By default, your Java classes have access to only the classes in java.lang.
- To refer to a class within a package, you must normally use the full package name. (e.g. Color class in java.awt package => java.awt.Color)

Exercises (P35)
- Ex 1. VolcanoRobot Exercise a robot named virgil: VolcanoRobot_exercise.java
- Ex 2. ChessPiece Exercise: Superclass = ChessPiece.java => class = Pawn.java (can create other piece classes)

=================================================================
New notes from "Sams Teach Yourself Java 6 in 21 Days"
=================================================================

- 1. VolcanoRobot.java file defines the VolcanoRobot class (notepad ++)
- 2. VolcanoRobotApplication.java file contains a class that has a special class method called main(). It uses the VolcanoRobot class defined in the other file. You only need to javac this file.

- The same things can be done in NetBean IDE. Just in a different order:
- 2. Create a project(java application) called VolcanoRobotApplication, a main() class method (in Main.java file) would be created. Write the main() class.
- 1. Create a java class called VolcanoRobot, a VolcanoRobot.java file would be created. Write the VolcanoRobot class.
- Personally I like the notepad ++ option above. Much simpler for a simple exercise. But NetBean makes running the application easier.