Download Computer Programming with JAVA

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
Computer Programming with
JAVA
Chapter 1
Introduction and A Taste of Java
Contents




Object-Oriented Programming
History of the Java Language
A First Java Program
Compiling and Running a Java Program
Computer
Programming with
Java
2
Object-Oriented Programming

What are Objects?

All things around us
• Ability to perform actions
• Status

OOP (or Paradigm)


A programming methodology (paradigm) that
views a program as this sort of world
consisting of objects that interact with each
other by means of actions.
Methods, data
Computer
Programming with
Java
3
Object-Oriented Programming
(1)

Objects
• A program construction that has data associated
with it and that can perform certain actions

Methods
• The actions performed by objects

Class
• A type or kind of object

What is difference between OOP and
Procedural-Oriented Programming?
Code reusability
Computer
 Efficiency
Programming with

Java
4
A Brief History of the Java
Language

A brief history of the Java

1990:
• Gosling, J. and Naughton, P.

1991: Green Project
• *7 system by 1st Person Inc. named by Oak
• Research settop box and VOD with Green (O.S.)
• Gosling, J., designing a programming language for
home appliances
• Java byte code: Intermediate language for
inexpensive portability

1991: WWW, 1992: Web browser
Computer
Programming with
Java
5
A Brief History of the Java
Language (1)

1994:
• NCSA Mosaic, WebRunner (HotJava) browser, applet

1995:
• adapted for New technology for WWW
• Netscape and MS agreed license of Java

1996:
• Java 1.0.2
Computer
Programming with
Java
6
A Taste of Java

Features
JAVA : A simple, Object-Oriented, distributed,
interpreted, robust, secure, machine-independent
(portable), high-performance, multi-thread, and
dynamic language
• Simple : No operator overloading, multiple
inheritance, memory management, header file,
structure, union, enumeration, pointer arithmetic,
template, preprocessing, user-defined type
conversion.
• Object-Oriented
• Distributed : WWW
• Robust : no memory management, exception
Computer handling, error checking in compile-time.

Programming with
Java
7
A Taste of Java (1)
• secure : public-key, restricted client resource access
• 자바 애플릿은 클라이언트 내의 디스크를 read/write할 수 없다.
• 자바 애플릿은 클라이언트의 다른 응용프로그램을 실행시킬 수 없다.
• 자바 애플릿은 다운로드된 서버 외에는 접속할 수 없다.
• Machine-Independent (portable)
• “Write Once Run Everywhere”
• Compiled : compiled into byte code
• Interpreted : bytecodes are interpreted by Java
Virtual Machine
• Multi-Thread
Computer
Programming with
Java
8
Server
Client
Java Applet
Bytecode verifier
Java Compiler
Java
Bytecodes
Applet
Store
Computer
Programming with
Java
Class loader
Java
Run-time
interpreter
Java
Bytecodes
Just-inTime
Compiler
Hardware
platform
Security model in Java
9
Source
code
Pentium
Pentium
executable
code
Mac
Mac
executable
code
Unix
Unix
executable
Machine-independent Property
Pentium
Java Interpreter
Pentium
Source
code
Mac
Unix
Computer
Programming with
Java
Java
Bytecodes
Mac
Java Interpreter
Unix
Java Interpreter
10
A Taste of Java (2)

Types of Java program

Applet
• To be sent to another (remote) location on the
WWW and run there.

Application
• Running on your (local) computer. main()

Byte Code


Executable code in the Java
Machine-independent, neutral, intermediate
code
Computer
Programming with
Java
11
A Taste of Java (3)

Difference between C++ and Java
Inheritance
Garbage Collection
Operator overloading
String
Type conversion
Computer
Programming with
Java
Java
C++
Single
Multiple
Automatic

Manual
o
Built-in class
Automatic
Character array
Manual
12
Java Development Kit

JDK


contains the software and tools that
developers need to compile, debug, and run
applets and applications written using the
Java programming language.
JDK 1.0
Just reflect the feature of language itself and
the one of Applet
 Sun didn’t pass through the alpha, beta
version, and just were intended on displaying
the bug-modified version
Computer
Programming
with : huge bugs and insufficient GUI
 problem

Java
13
Java Development Kit (1)

JDK 1.1


Event-driven model, light component
framework
JDBC, RMI, JavaBeans, Globalization, Localization API

Object Serialization
Servlet Api, Enterprise JavaBeans

자바가 Server측에 수용되는데 밑거름이 됨

Computer
Programming with
Java
14
Java Development Kit (2)

JDK 1.2




JDBC, RMI등의 기반 API들을 개선
2-Dimension Imagiing과 Printing, GUI
component Security Model
CORBA의 지원(org.*)
주로 client측의 S/W를 위한 API완성
Computer
Programming with
Java
15
Java Development Kit (3)

Java 2 Platform


Java 1.2의 정식 버젼
API관련
• Swing, 2D API, drag&drop API, JFC

Security관련
• Policy-Based Access Control

프로그래밍 관련
• 강력한 자료구조코딩을 위한 collection framework
• 참조객체지원
• Reflection과 Serialization에 대한 성능 개선

HotSpot은 포함되지 않음
Computer
Programming with
Java
16
public class FirstProgram{
public static void main(String[] args){
System.out.println("Hello out there.");
System.out.println("Want to talk some more?");
System.out.println("Answer y for yes or n for no.")
char answerLetter;
answerLetter = SavitchIn.readLineNonwhiteChar();
if(answerLetter == 'y')
System.out.println("Nice weather we are havin
System.out.println("Good-bye");
System.out.println("Press enter key to end program.
String junk;
junk = SavitchIn.readLine();
}
}
Computer
Programming with
Java
Display 1.4: A Simple Java Program
17
Spelling Rules

Identifier

A name in a programming language
• e.g.) a class or variable name

Rules





It must consist entirely of letters, digits (0-9), and
underscore character (_)
The first character cannot be a digit
No identifier can contain a space or any other character
such as a period or an *.
There is no limit to the length of a name
Case-Sensitive
• e.g.) mystuff, myStuff, Mystuff
Computer
Programming with
Java
18
Spelling Rules (1)

Unicode
• It can include characters that are used in other
languages

It must avoid the reserved words (or
keywords) and built-in classes and their
member
Computer
Programming with
Java
19
Compiling and Running a Java
Program

Compiling


javac MyClass.java
Running

java MyClass
Computer
Programming with
Java
20
Java source (.java)
(FirstProgram.java)
Java Compiler
(javac)
Java Bytecodes
(FirstProgram.class)
Java Interpreter
(java)
Computer
Display 1.3: Compiling
Programming with
Java
and Running a Java Program
21
Related documents