Intro to Java
-
Upload
karianneban -
Category
Technology
-
view
52 -
download
0
Transcript of Intro to Java
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
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
Characteristics of Java
Simple
Object-oriented
Interpreted
Multithreaded
Dynamic
Reference: http://docs.oracle.com/javase/tutorial/getStarted/intro/definition.html
Architecture neutral
Portable
High performance
Robust
Secure
DevelopmentJava Development Kit
Java Runtime Environment
Java Virtual Machine
Reference: http://www.javabeat.net/what-is-the-difference-between-jrejvm-and-jdk/
Compilation
Reference: http://docs.oracle.com/javase/tutorial/getStarted/intro/definition.html
Installation
Install Java http://support.apple.com/kb/DL1572
Install JDK http://www.oracle.com/technetwork/java/javase/download
s/jdk8-downloads-2133151.html
Install IntelliJ https://www.jetbrains.com/idea/download/
Similarities with Ruby
Object-oriented
Provide inheritance A class may extend only one other class
Public, private, protected modifiers
Automatic garbage collection
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
Constructors
Ruby uses the “initialize” keyword for all classesclass 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;
}
}
Naming Conventions
Packages Lowercase i.e. com.mycompany.util.package
Classes CamelCase
Interfaces CamelCase Starts with an “I” to denote interface (not required)
Methods, Variables mixedCase
Constants All caps
Exception Handling
Ruby
begin
rescue Exception1
rescue Exception2
ensure
end
Java
try {
}
catch (Exception e) {
}
finally() {
}
Multiple Inheritance
Ruby uses modules and mixins
Java uses interfaces that consist of abstract methods