Download Java -- A very Hot Object-Oriented Language

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

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

Document related concepts
no text concepts found
Transcript
Java -- A very Hot ObjectOriented Language
Instructors:
Fu-Chiung Cheng
(鄭福炯)
Associate Professor
Computer Science & Engineering
Tatung Institute of Technology
Java -- A very Hot ObjectOriented Language
Goals:
Learning Java Programming
&
Understanding Java and Java Technology
自我介紹
幼稚園:彰化縣溪湖糖廠幼稚園
小學:基隆市成功國小
國中:高雄縣旗山國中
高中:台南一中
大學:台中市東海大學資訊科學
研究所:台北市大同工學院資訊工程
當兵:花蓮八零五醫院少尉資訊官
留學:美國紐約市哥倫比亞大學資訊科學
Outline
• Why Java is HOT?
• What is Java?
• What is New? (Java vs C++/C)
Why Java is HOT?
• Write Once, Run Anywhere model.
• Network-Centric Computing (internet programming)
• Interactive Content and Animation (multithreading)
support APIs for both client & server applications
• Near guarantee that you can‘t run a bad program.
• WWW + Java gives the world a new way to think.
What is Java?
• Simple (compared to C++)
• Ture object-Orentied programming
• Distributed
• Robust
• Secure
• Archetectural Neutral
• Multithreaded
What is New?
• No global variables -- package.class.field
• No preprocessor -- import statement
• Unicode
• No pointers
• Garbage Collection
• Array and String are first class objects
• No goto statement
• Single Inheritance
• Java documentation generator
• Applet with Web browsers
What is New?
• Java documentation
• Rich Libraries:
A. 2D, 3D programming model
B. 2D animation API for video game
C. API for time-critical audio, vidio and MIDI data
D. Multithreading
E. Networking
F. Security
G. Exception handling
….
What is New?
• C++/C Compilation, linking & loading:
C++
Program
Compiler
Binary
File
linker &
Loader
MAC
MAC
MAC
PC
PC
PC
Sun
Sun
Sun
What is New?
• Java Compilation, linking, loading & verifying & JVM:
Java
Program
Compiler
Interpreter
JVM
MAC
MAC
PC
Sun
Java
ByteCode
PC
Sun
How Java Works?
Java
Program
Loader
Java
Compiler
Java
ByteCode
Verifier
Network or
File System
JVM
H
A
R
D
W
A
R
E
C/C++ Process Image
Heap
Stack
Text
• Text: compiled program code
(Functions or methods)
• Stack: local variables, parameters,
return address
• Heap: dynamic allocation memory
C: mallac and free
C++: new and delete
Java Process Image
Heap
Stack
Text
• Text: compiled program code
(Functions or methods)
• Stack: primitives
(char, byte, int, float, double, …)
handles (addresses) of objects,
parameters, return address
• Heap: dynamic allocation memory
create: new
delete: garbage collector
Java Programs
• Java standalone applications:
Fully access your system resources (e.g. read/write files).
• Java applets:
No read/write access
Can not standalone,
Need browsers (appletviewer, Netscape, IE).
Java Standalone Applications
Public class HelloWeb {
public static void main(String args[]) {
System.out.println(“Hello Web!”);
}
}
• Compilation:
javac HelloWeb.java ==> HelloWeb.class
• Execution:
java HelloWeb
Java Applets
Public class HelloWebApplet extend java.applet.Applet {
public void paint(java.awt.Graphs g) {
g.drawString(“Hello Web!”, 125, 95);
}
}
HTML:
<html>
<h3> Hello Web Applet Example </h3>
<applet code=”HelloWebApplet” width=300 height=200>
</applet>
</html>
Conclusions
• Java is a pure OO programming language
• Cross-platform applications
(Write Once Run Anywhere)
• WWW + Java gives the world a new way to think.
完成 Lecture 1 休息十分鐘!
Related documents