Introduction to Programming in Java: An Interdisciplinary Approach · Robert Sedgewick and Kevin Wayne · Copyright © 2008 · January 26, 2009 9:28 tt
Why Programming?
2
Languages
3
Why Java?
Java features.
Widely used.
Widely available.
Embraces full set of modern abstractions.
Variety of automatic checks for mistakes in programs.
Java economy.
Mars rover. $100 billion,
5 million developers
Cell phones.
Blu-ray Disc.
Web servers.
Medical devices.
Supercomputing. James Gosling
http://java.net/jag
…
4
Why Java?
Java features.
Widely used.
Widely available.
Embraces full set of modern abstractions.
Variety of automatic checks for mistakes in programs.
Caveat.
5
Why Java?
Java features.
Widely used.
Widely available.
Embraces full set of modern abstractions.
Variety of automatic checks for mistakes in programs.
Our approach.
Minimal subset of Java.
Develop general programming skills that are applicable to:
C, C++, C#, Perl, Python, Ruby, Matlab, Fortran, Fortress, …
6
A Rich Subset of the Java Language
if else Integer.parseInt()
for while Double.parseDouble() Primitive Numeric Types
+ - *
Programming in Java.
Create the program by typing it into a text editor, and
save it as HelloWorld.java
/*******************************************
* Prints "Hello, World"
* Everyone's first Java program.
*******************************************/
HelloWorld.java
9
Programming in Java
Programming in Java.
Create the program by typing it into a text editor, and
save it as HelloWorld.java
Compile it by typing at the command-line:
javac HelloWorld.java
command-line
% javac HelloWorld.java
10
Programming in Java
Programming in Java.
Create the program by typing it into a text editor, and
save it as HelloWorld.java
Compile it by typing at the command-line:
javac HelloWorld.java
Execute it by typing at the command-line:
java HelloWorld
command-line
% javac HelloWorld.java
% java HelloWorld
Hello, World
1.2
11
Dr. Java
http://drjava.org
Dr. Java
compile
13
Dr. Java
command-line argument
14
Java Features
Simple.
Complex.
Fast.
Secure.
Extensible.
Well-understood.
Fun.
16
Java Bytecode
HelloWorld.class
17