Definitions
- Based on real-world examples
- -- objects are made up of many smaller parts, like Legos
- Classes
- templates for multiple objects with similar features
- Tree class (it has leaves and roots and can grow)
- You can create instances of a tree with different features
- Instance
- a specific concrete representation of a class. Equivalent to objects
- Instance variables
- defines the attributes about the object, ie. the data
- the tree has leaves and roots
- Methods
- functions defined by the object that operate on instances of that object
class Tree {
Leaf[] leaves;
Root[] roots;
void grow() {
<- Code for growing ->
}
}
"Java: A simple, object-oriented, distributed, interpreted, robust, secure, architecture neutral, portable, high-performance, multithreaded, and dynamic language." - "The Java Language: A White Paper
- Developed by James Gosling at Sun Microsystems in 1991 as part of a research project to develop software for TVs, VCRs, toasters, etc.
- Originally known as "Oak"
- Commercially released in 1995
- Architecture neutral
Traditional languages need to be compiled for a specific hardware architecture.
Java allows the program to be written once and run everywhere.
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello World!");
}
}I couldn't resist.