Java Programming Introduction
Java Programming Introduction
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All
rights reserved. 0132130807
Computer Programming
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All
rights reserved. 0132130807
Assembly Language
• Assembly language is a low-level programming language in
which a mnemonic is used to represent each of the machine
language instructions. For example, to add two numbers, we
might write an instruction in assembly code like this: ADDF3 R1,
R2, R3
• Since the computers cannot understand assembly language, a
program called an assembler is used to convert assembly-
language programs into machine code
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All
rights reserved. 0132130807
High Level Programming Languages
• As program size grows, assembly program becomes
unmanageable
• The high-level languages are English-like and easy to learn and
program. Here, for example, is a high-level language statement
that computes the area of a circle with radius 5: area = 5
* 5 * 3.1415;
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All
rights reserved. 0132130807
Prominent High Level Programming
Languages
COBOL (COmmon Business Oriented Language)
FORTRAN (FORmula TRANslation)
BASIC (Beginner’s All-purpose Symbolic Instruction Code)
Pascal (named for Blaise Pascal)
Ada (named for Ada Lovelace)
C (developed by the designer of B)
Visual Basic (Basic-like visual language by Microsoft)
Delphi (Pascal-like visual language developed by Borland)
C++ (an object-oriented language, based on C)
C# (a Java-like language developed by Microsoft)
Java
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All
rights reserved. 0132130807
Why Java?
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All
rights reserved. 0132130807
History of Java
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All
rights reserved. 0132130807
Java Development Kit (JDK) Versions
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All
rights reserved. 0132130807
JDK Editions
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All
rights reserved. 0132130807
Application Program and Operating Systems
(OS)
• The operating system(OS) is the
most important program that runs
on a computer, which manages
and controls a computer’s
activities
• OS abstracts the hardware from
the users
• Users do not need to know the
details of the HW
• Using application programs such
as a web browser or a word
processor, users utilize hardware
components through OS
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All
rights reserved. 0132130807
• Write a program
• Compile the program
• Hello.c => compiler => hello.exe
• Hello.exe => Windows 10
byte code
• hello.java
• hello.java => javac => hello.class [is not directly executable on OS]
• hello.class => Java Virtual Machine (software machine on top of
machine)
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All 11
rights reserved. 0132130807
• hello.c => after compilation => hello.exe -- execute (Windows)
• hello.c - after compilation hello.out execute (Linux)
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All 12
rights reserved. 0132130807
Java Program Execution
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All
rights reserved. 0132130807
Java Bytecode and JVM
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All
rights reserved. 0132130807
Anatomy of a Java Program
• Comments
• Reserved words
• Modifiers
• Statements
• Blocks
• Classes
• Methods
• The main method
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All
rights reserved. 0132130807
Smallest Java Program
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All
rights reserved. 0132130807
Integrated Development Environment (IDE)
• Eclipse
• Command Prompt
• javac program_name.java
• Java program_name
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All
rights reserved. 0132130807