3. Plan of Attack
History and Impact of Java
Characteristics of Java
Development and Compilation in Java
Installing IDE
Similarities with Ruby
Differences with Ruby
Objects, Variables, Classes, Constructors, Methods, Exception Handling,
Multiple Inheritance
Examples
5. History and Impact of Java
Created by Sun Microsystems in 1995
Largely derived and simplified from C++
“Write once, run anywhere”
Amazon, Facebook, Google, Square, Twitter
https://blog.twitter.com/2011/twitter-search-now-3x-faster
10. Similarities with Ruby
Object-oriented
Provide inheritance
A class may extend only one other class
Public, private, protected modifiers
Automatic garbage collection
11. Objects
Ruby
Everything is an object, including classes and instances of
types
Java
Primitive data types – do not extend object class
int, double, boolean, char, etc.
Strings have special support from java.lang.String
class
Immutable
Technically not a primitive data type
14. Constructors
Ruby uses the “initialize” keyword for all classes
class Dog
def initialize(breed)
@breed = breed
end
end
Java requires the public keyword and class name
public class Dog(){
public Dog(String breed){
this.breed = breed;
}
}
WORA means that compiled Java code can run on all platforms that support Java without the need for recompilation
Simple - relative to C++
Interpreted -
JDK includes dev tools and the JRE
Compiler: javac
Java archiver: JAR
Dissassembler: javap
JRE contains JVM, class libraries no tools like the compiler
Java: launches app
Javaw: launches w.o console
Rt.jar: compiled class files
Ruby is an interpreted scripting language, whereas Java is a compiled programming language
Ruby is run directly without first needing to be compiled
Why interpreted?
Compiled into .class files by the javac compiler
The .class file contains bytecodes (rather than architecture-specific machine code) – the language of the JVM
The JVM converts the bytecode to machine code based on the operating system - capable of running on Microsoft Windows, the Solaris™ Operating System (Solaris OS), Linux, or Mac OS
Just as Ruby on Rails is the framework for developing MVC apps, Java EE is the Java equivalent
Ruby is dynamically typed so type declarations are not used
Java is statically typed so type declarations are required
Class definition
Ruby defines blocks using the ‘end’ keyword
Java defines blocks using the brackets
In ruby, class definitions do not have an access modifier
Class instantiation
Ruby does not use type declarations b/c it is dynamically typed
Java requires type declarations b/c it is statically typed
Ruby methods may return values but the type is not specified in the method definition
Ruby methods are public by default
Abstract methods are then implemented by the class that is implementing the interface