Materi 01 - Introduction To Java Programming
Materi 01 - Introduction To Java Programming
Java Programming
Y. Daniel Liang
Introduction
What is a computer?
Electronic devices that stores and process data
Includes both hardware and software
Hardware
control unit
controls and coordinates the actions of the other components
arithmetic/logic unit
perform numeric operations (addition, subtraction,
multiplication, division)
Perform logic operations (comparison)
Hardware
Hardware
Hardware
Hardware
Hardware
Software
Software/computer program
invisible instructions that control the hardware and
make it perform specific tasks.
Tell computer what to do in computer/machine
language
Software
Computer languages
1. Machine language
2. Assembly language
3. High level language
Software
Machine language
a set of primitive instructions built into every
computer
Different for different types of computers.
The instructions are in the form of binary code,
e.g. to add 2 numbers (very tedious):
1101101010011010
Software
Assembly language
Low-level programming language which uses
mnemonic to represent machine-language
instructions
E.g.: ADDF3 R1, R2, R3
Assembly code need to be converted into
machine code by using an assembler
Assembly program
is platform dependent
Combination of mnemonic and machine instruction
Software
High-level language
English-like and easy to learn and program.
E.g.:
Area = 5 * 5 * 3.1415;
Software
Source:
http://java.sun.com/docs/books/tutorial/getStarted/intro/definition.html
Through the
Java VM, the
same
application is
capable of
running on
multiple
platforms.
Source:
http://java.sun.com/docs/books/tutorial/getStarted/intro/definition.html
Software
Software
What Is Java?
History
Characteristics of Java
History
James Gosling
HotJava
The first Java-enabled Web browser
Characteristics of Java
Java is simple
Java is object-oriented
Java is distributed
Java is interpreted
Java is robust
Java is secure
Java is architecture-neutral
Java is portable
Javas performance
Java is multithreaded
Java is dynamic
Inprise JBuilder
Symantec Caf
API
Contains predefined classes and interfaces for
developing Java programs.
3 editions of Java API
JDK
A set of programs for developing and testing
Java program, each of which is invoked from a
command line.
Java Application
Compiling
Programs
Executing Applications
A Simple Application
Example 1.1
//This application program prints Welcome
//to Java!
public class Welcome
{
public static void main(String[] args)
{
System.out.println("Welcome to Java!");
}
}
Source
Run
Compiling Programs
On command line
javac file.java
Executing Applications
On command line
java classname
Bytecode
Java
Interpreter
on Windows
Java
Interpreter
on Linux
...
Java
Interpreter
on Sun Solaris
Example
javac Welcome.java
java Welcome
output:...
Comments
Modifier
Certain reserved words are modifiers that specify the
properties of the data, methods and class and how they
can be used.
E.g: public, private, static, final, abstract, protected.
Statement
Represents an action or a sequence of actions
Ends with semicolon (;)
Block
Groups the components of the program
Begins with opening brace { and ends with a closing
brace }
Class block, method block
Class
Program is defined by using one or more class
Will be covered in more details later.
Method
A collection of statements that perform a sequence of
operations.
Can be used without fully understanding how it works.
Invoke by calling the method name with the
requirement argument
Summary