1 / 19

CHAPTER 1

CHAPTER 1. INTRODUCTION. CHAPTER GOALS. To understand the activity of programming To learn about the architecture of computers To learn about machine code and high level programming languages To become familiar with your computing environment and your compiler

shing
Télécharger la présentation

CHAPTER 1

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CHAPTER 1 INTRODUCTION

  2. CHAPTER GOALS • To understand the activity of programming • To learn about the architecture of computers • To learn about machine code and high level programming languages • To become familiar with your computing environment and your compiler • To compile and run your first Java program • To recognize syntax and logic errors

  3. PREREQUISITES • Computer savvy (file management, text editing) • Problem solving skills • Time management • High school math (algebra, trigonometry) • No prior programming background required

  4. What is a computer? • Central processing unit • Memory • Peripherals • Executes very simple instructions • Executes instructions very rapidly • General purpose device • Programs describe specific actions

  5. Central Processing Unit

  6. Schematic Diagram of a Computer

  7. Programming Languages • Machine/Virtual Machine21 40 16 100 163 240 • Assembleriload intRatebipush 100if_icmpgt intError • High-level languageif (intRate > 100) . . .

  8. The Java Programming Language • Simple • Safe • Platform-independent ("write once, run anywhere") • Rich library • Designed for the internet

  9. Applets on a Web Page

  10. Becoming Familiar with your Computer • Login • Locate the Java compiler • Understand files and folders • Write a simple program (later) • Save your work

  11. A Shell Window

  12. An Integrated Development Environment

  13. File Hello.java 1 public class Hello 2 { 3 public static void main(String[] args) 4 { 5 // display a greeting in the console window 6 System.out.println("Hello, World!"); 7 } 8 }

  14. A simple program • public class ClassName • public static void main(String[] args) • // comment • Method call object.methodName(parameters) • System class • System.out object • println method

  15. Syntax 1.1: Method Call • object.methodName(parameters) • Example: • System.out.println("Hello, Dave!"); • Purpose: • To invoke a method of an object and supply any additional parameters

  16. Compiling and Running • Type program into text editor • Save • Open command shell • Compile into byte codesjavac Hello.java • Execute byte codesjava Hello

  17. From Source Code to Running Program

  18. Errors • Syntax errorsSystem.ouch.print("...");System.out.print("Hello); • Detected by the compiler • Logic errorsSystem.out.print("Hell"); • Detected (hopefully) through testing

  19. The Edit-Compile-Test Loop

More Related