Download Media:IntroJava

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
Introduction to Java
IB Computer Science II
Paul Bui
What does a computer look like?
Central
Processing
Unit
(CPU)
Memory
What is a computer program?
1010111101010101001100100000111
0101101011110101010100110010000
0111010101111010101010011001000
0011101010111101010101001100100
0001110101011110101010100110010
0000111010101111010101010011001
0000011101010111101010101001100
1000001110101011110101010100110
0100010010000011101010111101010
Assembly Language



Also known as machine code/language or
low-level language
Example:
ADD R1, R2, R3
SUB R1, R1, 1
MULT R3, R1, R2
Why can’t I run my PC programs on a
Mac?!?!?

Different from machine to machine
I Hate Tedious Stuff


Old school programs
Invention of the high-level language
ADD R1, R2, R3
SUB R1, R1, 1
MULT R4, R1, R2


D = B*(B+C-1)
Waaaay easier to understand
Compilers


Translates or converts a high-level
language (e.g., Java, C++) to a lowlevel language
Does other stuff too!




Checks syntax
Optimizations
and more!
One would say, “Yeah, so I compiled
my code to an executable or binary”
Before Java…
Applications or Programs
Operating System (Windows XP, Mac OSX, etc.)
Hardware (CPU + Memory + etc.)
How Java Works
Java Application or Java Program
Java Runtime Environment or Java Virtual Machine
Operating System (Windows XP, Mac OSX, etc.)
Hardware (CPU + Memory + etc.)
What does this mean?

Java bytecode (Java’s low-level
language)
Java sourcecode (high-level)  Java bytecode (low-level) 
assembly

Two different operating systems with
the JRE or JVM can run the same
Java program
Ok, so I want to program now!
//My first Java program!
class HelloWorld{
public static void main(String[] args) {
System.out.println("Hello World!");
}
}
How to Compile and Execute
1)
2)
3)
Open a text editor (gedit, tea, vi, etc.)
Code Code Code
Save file as CLASSNAME.java
Example: HelloWorld.java
4)
5)
6)
Open a terminal
javac HelloWorld.java
java HelloWorld
Related documents