©2000, John Wiley & Sons, Inc. Horstmann/Java Essentials, 2/e Chapter 1: Introduction 1 Chapter 1 Introduction.

Slides:



Advertisements
Similar presentations
Chapter 1 These slides for CSE 110 Sections are based in part on the textbook-authors’ slides, which are copyright by the authors. The authors state that.
Advertisements

How do we make our Welcome.java program do something? The java in our Welcome.java file won’t do anything by itself. We need to tell the computer to execute.
The Java Programming Language  Simple – but abstract  Safe  Platform-independent ("write once, run anywhere")  Has a Rich growing library  Designed.
Slides prepared by Rose Williams, Binghamton University Chapter 1 Getting Started 1.1 Introduction to Java.
How do we make our HelloTester.java program do something? The java in our HelloTester.java file won’t do anything by itself. We need to tell the computer.
CHAPTER 1 INTRODUCTION GOALS  To understand the activity of programming  To learn about the architecture of computers  To learn about machine code and.
CHAPTER 2 OBJECTS AND CLASSES Goals: To understand the concepts of classes and objects To realize the difference between objects and object references.
Copyright © 2012 Pearson Education, Inc. Chapter 1: Introduction to Computers and Programming.
Aalborg Media Lab 21-Jun-15 Software Design Lecture 1 “ Introduction to Java and OOP”
Java Intro. A First Java Program //The Hello, World! program in Java public class Hello { public static void main(String[] args) { System.out.println("Hello,
CS211 Data Structures Sami Rollins Fall 2004.
CS 101 Problem Solving and Structured Programming in C Sami Rollins Spring 2003.
ALGORITHMS CSC 171 LECTURE 1. What is “Computer Science”? What is “Science”? What is a “Computer”? What is “Computation”?
Chapter 1 - Introduction. Ch 1Goals To understand the activity of programming To learn about the architecture of computers To learn about machine code.
CS190/295 Programming in Python for Life Sciences: Lecture 1 Instructor: Xiaohui Xie University of California, Irvine.
IB Computer Science II Paul Bui
CS102 Introduction to Computer Programming
Alternate Version of STARTING OUT WITH C++ 4 th Edition Chapter 1 Introduction to Computers and Programming.
Chapter Introduction to Computers and Programming 1.
Week 1 Introduction to Computer Science and Object-Oriented Programming COMP 111 George Basham.
An intro to programming. The purpose of writing a program is to solve a problem or take advantage of an opportunity Consists of multiple steps:  Understanding.
Copyright © 2012 Pearson Education, Inc. Chapter 1: Introduction to Computers and Programming 1.
Copyright © 2012 Pearson Education, Inc. Chapter 1: Introduction to Computers and Programming.
Chapter 1: Introduction to Computers and Programming.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 1: Introduction to Computers and Programming.
Copyright © 2013 by John Wiley & Sons. All rights reserved. INTRODUCTION CHAPTER Slides by Donald W. Smith TechNeTrain.com Final Draft Oct. 15,
CS 106 Introduction to Computer Science I 01 / 25 / 2010 Instructor: Michael Eckmann.
©Xiaoying Gao, Peter Andreae First Java Program COMP 102 #2 2014T2 Xiaoying Sharon Gao Computer Science Victoria University of Wellington.
Big Java by Cay Horstmann Copyright © 2008 by John Wiley & Sons. All rights reserved. Chapter One: Introduction.
Week 1 Introduction to Computer Science and Object-Oriented Programming COMP 111 George Basham.
Introduction to Computers and Java Chapter 1.3. A Sip of Java: Outline History of the Java Language Applets A First Java Program Compiling a Java Program.
Chapter 1 Introduction. Goal to learn about computers and programming to compile and run your first Java program to recognize compile-time and run-time.
First Java Program COMP 102 #2 2015T2 Xiaoying Sharon Gao Computer Science Victoria University of Wellington.
Chapter 1 CSIS-120: Java Intro. What is Programming?  A: It is what makes computer so useful.  The flexibility of a computer is amazing  Write a term.
Big Java by Cay Horstmann Copyright © 2009 by John Wiley & Sons. All rights reserved. Chapter 1 – Introduction.
© 2012 Pearson Education, Inc. All rights reserved. 1-1 Why Java? Needed program portability – Program written in a language that would run on various.
ICOM 4015: Advanced Programming Lecture 1 Big Java by Cay Horstmann Copyright © 2009 by John Wiley & Sons. All rights reserved. Reading: Chapter One: Introduction.
Java Programming, Second Edition Chapter One Creating Your First Java Program.
1 Programming Fundamentals AITI-GP. 2 Introduction to Programming.
Big Java by Cay Horstmann Copyright © 2008 by John Wiley & Sons. All rights reserved. Chapter One: Introduction.
Big Java by Cay Horstmann Copyright © 2009 by John Wiley & Sons. All rights reserved. Chapter 1 – Introduction ( ปรับปรุง )
Copyright © 2014 by John Wiley & Sons. All rights reserved.1 Chapter 1 - Introduction.
CHAPTER 1 INTRODUCTION. CHAPTER GOALS To understand the activity of programming To understand the activity of programming To learn about the architecture.
Fall 2006Slides adapted from Java Concepts companion slides1 Introduction Advanced Programming ICOM 4015 Lecture 1 Reading: Java Concepts Chapter 1.
Jens Dalsgaard Nielsen Jan Dimon Bendtsen Dept. of Electronic Systems Basic Programming INS-basis GF, PDP and HST.
INM205 Object Oriented Programming in JAVA Dr. Michael Casey Department of Computing.
Chapter 1 Computers, Compilers, & Unix. Overview u Computer hardware u Unix u Computer Languages u Compilers.
Chapter 1 Introduction. Chapter Goals To understand the activity of programming To learn about the architecture of computers To learn about machine code.
A.Abhari CPS1251 Topic 1: Introduction to Computers Computer Hardware Computer components Connecting Computers Computer Software Operating System (OS)
CHAPTER 1 INTRODUCTION. CHAPTER GOALS To understand the activity of programming To learn about the architecture of computers To learn about machine code.
Lecture1 Instructor: Amal Hussain ALshardy. Introduce students to the basics of writing software programs including variables, types, arrays, control.
1. COMPUTERS AND PROGRAMS Rocky K. C. Chang September 6, 2015 (Adapted from John Zelle’s slides)
Computer Science A 1. Course plan Introduction to programming Basic concepts of typical programming languages. Tools: compiler, editor, integrated editor,
CompSci 42.1Intro to Java Anatomy of a Class & Terminology Running and Modifying a Program.
Chapter 1: Introduction to Computers and Programming.
Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 1: Introduction to Computers and Programming.
A Simple Object Oriented Program public class Simple { public static void main (String [] args) { System.out.println(“howdy”); } System.out is an object.
Introduction to Object Oriented
Chapter 1 – Introduction
Department of Computer Science,
John Woodward A Simple Program – Hello world
Chapter 1 – Introduction
Goals To learn about computers and programming
CS190/295 Programming in Python for Life Sciences: Lecture 1
Mobile Development Workshop
Introduction to Algorithm Design
Java Intro.
IB Computer Science II Paul Bui
AN INTRODUCTION TO OBJECTS AND CLASSES
Computer Programming-1 CSC 111
Presentation transcript:

©2000, John Wiley & Sons, Inc. Horstmann/Java Essentials, 2/e Chapter 1: Introduction 1 Chapter 1 Introduction

©2000, John Wiley & Sons, Inc. Horstmann/Java Essentials, 2/e Chapter 1: Introduction 2 Welcome to CS46A Green Sheet Register for Companion Lab Send to add First homework due September 7

©2000, John Wiley & Sons, Inc. Horstmann/Java Essentials, 2/e Chapter 1: Introduction 3 Course Goals Introduction to computer science Programming concepts Problem solving Object-oriented programming Introduction to Java (but not a Java course) Foundation for CS majors

©2000, John Wiley & Sons, Inc. Horstmann/Java Essentials, 2/e Chapter 1: Introduction 4 Prerequisites Computer savvy (file management, text editing) Problem solving skills Time management High school math (algebra, trigonometry) No prior programming background required

©2000, John Wiley & Sons, Inc. Horstmann/Java Essentials, 2/e Chapter 1: Introduction 5 What is a computer? Central processing unit Memory Peripherals Executes very simple instructions Executes instructions very rapidly General purpose device Programs describe specific actions

©2000, John Wiley & Sons, Inc. Horstmann/Java Essentials, 2/e Chapter 1: Introduction 6 Figure 1 Central Processing Unit

©2000, John Wiley & Sons, Inc. Horstmann/Java Essentials, 2/e Chapter 1: Introduction 7 Figure 2 CPU Chip Detail

©2000, John Wiley & Sons, Inc. Horstmann/Java Essentials, 2/e Chapter 1: Introduction 8 Figure 3 RAM Chips

©2000, John Wiley & Sons, Inc. Horstmann/Java Essentials, 2/e Chapter 1: Introduction 9 Figure 4 A Hard Disk

©2000, John Wiley & Sons, Inc. Horstmann/Java Essentials, 2/e Chapter 1: Introduction 10 Figure 5 A High-Capacity Floppy Disk and Its Drive

©2000, John Wiley & Sons, Inc. Horstmann/Java Essentials, 2/e Chapter 1: Introduction 11 Figure 6 A CD-ROM Drive

©2000, John Wiley & Sons, Inc. Horstmann/Java Essentials, 2/e Chapter 1: Introduction 12 Figure 7 Tape Backup Drives and Data Tape

©2000, John Wiley & Sons, Inc. Horstmann/Java Essentials, 2/e Chapter 1: Introduction 13 Figure 8 A Personal Computer

©2000, John Wiley & Sons, Inc. Horstmann/Java Essentials, 2/e Chapter 1: Introduction 14 Figure 9 A Motherboard

©2000, John Wiley & Sons, Inc. Horstmann/Java Essentials, 2/e Chapter 1: Introduction 15 Figure 10 Schematic Diagram of a Personal Computer

©2000, John Wiley & Sons, Inc. Horstmann/Java Essentials, 2/e Chapter 1: Introduction 16 Programming Languages Machine/Virtual Machine Assembler iload intRate bipush 100 if_icmpgt intError High-level language if (intRate > 100)...

©2000, John Wiley & Sons, Inc. Horstmann/Java Essentials, 2/e Chapter 1: Introduction 17 The Java Programming Language Simple Safe Platform-independent ("write once, run anywhere") Rich library Designed for the internet

©2000, John Wiley & Sons, Inc. Horstmann/Java Essentials, 2/e Chapter 1: Introduction 18 Figure 12 An Applet on a Web Page

©2000, John Wiley & Sons, Inc. Horstmann/Java Essentials, 2/e Chapter 1: Introduction 19 Becoming Familiar with your Computer Login Locate the Java compiler Understand files and folders Write a simple program (later) Save your work

©2000, John Wiley & Sons, Inc. Horstmann/Java Essentials, 2/e Chapter 1: Introduction 20 Figure 13 A Startup Screen with Icons

©2000, John Wiley & Sons, Inc. Horstmann/Java Essentials, 2/e Chapter 1: Introduction 21 Figure 14 A Directory Hierarchy

©2000, John Wiley & Sons, Inc. Horstmann/Java Essentials, 2/e Chapter 1: Introduction 22 Figure 15 Screen Layout of an Integrated Java Environment

©2000, John Wiley & Sons, Inc. Horstmann/Java Essentials, 2/e Chapter 1: Introduction 23 A simple program public class ClassName public static void main(String[] args) object.methodName(parameters) System class System.out object println method

©2000, John Wiley & Sons, Inc. Horstmann/Java Essentials, 2/e Chapter 1: Introduction 24 Program Hello.java public class Hello { public static void main(String[] args) { System.out.println("Hello, World!"); }

©2000, John Wiley & Sons, Inc. Horstmann/Java Essentials, 2/e Chapter 1: Introduction 25 Compiling and Running Type program into text editor Save Open command shell Compile into byte codes javac Hello.java Execute byte codes java Hello

©2000, John Wiley & Sons, Inc. Horstmann/Java Essentials, 2/e Chapter 1: Introduction 26 Figure 16 From Source Code to Running Program

©2000, John Wiley & Sons, Inc. Horstmann/Java Essentials, 2/e Chapter 1: Introduction 27 Edi t– Compil e– Debug Loop Figure 17

©2000, John Wiley & Sons, Inc. Horstmann/Java Essentials, 2/e Chapter 1: Introduction 28 Errors Syntax errors System.ouch.print("..."); System.out.print("Hello); Detected by the compiler Logic errors System.out.print("Hell"); Detected (hopefully) through testing

©2000, John Wiley & Sons, Inc. Horstmann/Java Essentials, 2/e Chapter 1: Introduction 29 Objects and Classes Object: entity that you can manipulate in your programs (by invoking methods) Each object belongs to a class Class: Set of objects with the same behavior Class determines legal methods "Hello".println() // Error "Hello".length() // OK

©2000, John Wiley & Sons, Inc. Horstmann/Java Essentials, 2/e Chapter 1: Introduction 30 A Class has 4 Purposes: A class specifies which methods you can apply to its objects A class is a factory for objects ( new ) A class is a holding place for static methods and objects ( main, System.out ) A class defines implementation details: object fields and code for methods

©2000, John Wiley & Sons, Inc. Horstmann/Java Essentials, 2/e Chapter 1: Introduction 31 Rectangle class Construct a rectangle: new Rectangle(5, 10, 20, 30) new Rectangle() Object variables: Rectangle cerealBox = new Rectangle(5, 10, 20, 30); Rectangle crispyCrunchy; Sharing objects: crispyCrunchy = cerealBox;

©2000, John Wiley & Sons, Inc. Horstmann/Java Essentials, 2/e Chapter 1: Introduction 32 Figure 18 Rectangular Shapes

©2000, John Wiley & Sons, Inc. Horstmann/Java Essentials, 2/e Chapter 1: Introduction 33 Figure 19 Rectangle Objects

©2000, John Wiley & Sons, Inc. Horstmann/Java Essentials, 2/e Chapter 1: Introduction 34 Objec t Refers to an An Object Variable That Figure 20

©2000, John Wiley & Sons, Inc. Horstmann/Java Essentials, 2/e Chapter 1: Introduction 35 An Uninitialized Object Variable Figure 21

©2000, John Wiley & Sons, Inc. Horstmann/Java Essentials, 2/e Chapter 1: Introduction 36 Figure 22 Two Object Variables That Refer to the Same Object

©2000, John Wiley & Sons, Inc. Horstmann/Java Essentials, 2/e Chapter 1: Introduction 37 Rectangle class 2 Print a rectangle System.out.println(cerealBox); Translate a rectangle cerealBox.translate(15, 25) Import statement: import java.awt.Rectangle;

©2000, John Wiley & Sons, Inc. Horstmann/Java Essentials, 2/e Chapter 1: Introduction 38 Program MoveRectangle.java import java.awt.Rectangle; public class MoveRectangle { public static void main(String[] args) { Rectangle cerealBox = new Rectangle(5, 10, 20, 30); cerealBox.translate(15, 25); System.out.println(cerealBox); }

©2000, John Wiley & Sons, Inc. Horstmann/Java Essentials, 2/e Chapter 1: Introduction 39 Algorithms 1 Example: You put $10,000 into a bank account that earns 5% interest per year. Interest is compounded annually. How many years does it take for the account balance to be double the original?

©2000, John Wiley & Sons, Inc. Horstmann/Java Essentials, 2/e Chapter 1: Introduction 40 Algorithms 2 Unambiguous Executable Terminating If you can't find an algorithm, the computer can't solve your problem