Overview of Intro. to Java Programming
Transcript of Overview of Intro. to Java Programming
Overview of Intro. to
Java ProgrammingHui Chen
Department of Computer & Information Science
Brooklyn College
8/26/2021 CUNY | Brooklyn College 1
Objectives
• To understand computer basics, programs, and operating systems
• To understand the meaning of Java language specification, API, JDK, and IDE
• To write a simple Java program
• To display output on the console
• To explain the basic syntax of a Java program
• To create, compile, and run Java programs
8/26/2021 CUNY | Brooklyn College 2
Outline
• What is a computer?
• What is a program?
• What is a programing language?
• How do we let a computer run a program?
• What is an operating system?
• Why Java?
• How do we write a simple Java program?
8/26/2021 CUNY | Brooklyn College 3
What is a computer?
8/26/2021 CUNY | Brooklyn College 4
Components of Computers
• CPU
• Memory and Storage
• Input and Output Devices
• Communication Devices
8/26/2021 CUNY | Brooklyn College 5
CPU
• Instruction set
• Clock speed
• Cache
• Multi-core CPUs
8/26/2021 CUNY | Brooklyn College 6
Memory Hierarchy
• Roles
• Main memory
• Secondary storage
• Tertiary storage (backup)
• Characteristics
• Volatile vs non-volatile
• Access latency (speed)
• Capacity (size)
• Reliability (e.g., MTBF)
8/26/2021 CUNY | Brooklyn College 7
How Data is Stored?
• Representation
• Binary representation
• Bits and Bytes
• Units of measurement
• Addressing
8/26/2021 CUNY | Brooklyn College 8
Input and Output Devices
• Input devices
• Mouse, keyboard, touch pad, joy sticker, …
• Output devices
• Monitor
• Resolution
• Dot pitch
• Printer
8/26/2021 CUNY | Brooklyn College 9
Communication Devices
• Examples
• Bluetooth
• Ethernet
• Wireless LAN (e.g., Wi-Fi)
8/26/2021 CUNY | Brooklyn College 10
Questions?
8/26/2021 CUNY | Brooklyn College 11
What is a program?
• (computer) hardware vs. (computer) software
• Programs are software
• Instructions to a computer, written in a
programming language
8/26/2021 CUNY | Brooklyn College 12
Questions?
8/26/2021 CUNY | Brooklyn College 13
What is a programming language?
• Machine language
• Assembly language
• High-level language
8/26/2021 CUNY | Brooklyn College 14
Examples of High-Level Languages
8/26/2021 CUNY | Brooklyn College 15
Questions?
8/26/2021 CUNY | Brooklyn College 16
How do we let a computer run a
program?
• How do we let a computer run a program written in
a high-level (or assembly) language?
• Source code, interpreter, and compiler
• Interpreting
• Compilation
8/26/2021 CUNY | Brooklyn College 17
Questions?
8/26/2021 CUNY | Brooklyn College 18
What is an operating system?
• Examples of operating systems?
• What does an operating system do?
8/26/2021 CUNY | Brooklyn College 19
Questions?
8/26/2021 CUNY | Brooklyn College 20
Why Java?
• Java is a general purpose high-level programming
language? But why?
• JRE vs JDK
8/26/2021 CUNY | Brooklyn College 21
Questions?
8/26/2021 CUNY | Brooklyn College 22
Writing a simple Java program?
• Preferred development environment
• Git bash + Atom editor + JDK 1.8 or newer
• (Optional) Using IDEs
• IntelliJ IDEA
• Eclipse
• NetBeans
• …
8/26/2021 CUNY | Brooklyn College 23
Let’s write a simple Java program
• Class name
• Main method
• Statements
• Statement terminator
• Reserved words
• Comments
• Blocks
8/26/2021 CUNY | Brooklyn College 24
What if there is an error?
• What kind of error?
• How do we deal with errors?
8/26/2021 CUNY | Brooklyn College 25
Questions?
8/26/2021 CUNY | Brooklyn College 26
Assignments
• Journal Exercise 1
• Journal Exercise 2
• CodeLab Assignment 0
8/26/2021 CUNY | Brooklyn College 27
(Journal) Exercise 1
• Preparing programming environment
• Download and set up Git, Atom, JDK
• Optionally, using an IDE
• Create a journal directory (e.g., journal), and create
a subdirectory (e.g., C0826)
• Document the experience (concisely) in a text file
8/26/2021 CUNY | Brooklyn College 28
(Journal) Exercise 2
• Write, compile, and run the “Hello, World” java
program
1. Create/Revise the program
2. Compile the program
3. Run the program
4. Introduce errors on purpose (e.g., remove “;”, remove
“(“, remove “}”, change “main” to “primary”), repeat 1
- 3
8/26/2021 CUNY | Brooklyn College 29
(CodeLab) Exercise 0
• Complete CodeLab registration
8/26/2021 CUNY | Brooklyn College 30