1.1 Your First Program Introduction to Programming in Java: An Interdisciplinary Approach · Robert Sedgewick and Kevin Wayne · Copyright © 2008 · October.

Slides:



Advertisements
Similar presentations
Designing a Program & the Java Programming Language
Advertisements

Lecture 0 CSIS10A Overview. Welcome to CSIS10A (5 mins) – Typical format for class meetings New material first (monitors off, notebooks out) Practice.
IC211 Object Oriented Programming Overview of Java.
Introduction to Java CS 331. Introduction Present the syntax of Java Introduce the Java API Demonstrate how to build –stand-alone Java programs –Java.
Slide 1 of 40. Lecture A The Java Programming Language Invented 1995 by James Gosling at Sun Microsystems. Based on previous languages: C, C++, Objective-C,
1 Programming & Programming Languages Overview l Machine operations and machine language. l Example of machine language. l Different types of processor.
COMP 14: Intro. to Intro. to Programming May 23, 2000 Nick Vallidis.
Hello, world! Dissect HelloWorld.java Compile it Run it.
Lecture 1: Overview of Java. What is java? Developed by Sun Microsystems (James Gosling) A general-purpose object-oriented language Based on C/C++ Designed.
01 Introduction to Java Technology. 2 Contents History of Java What is Java? Java Platforms Java Virtual Machine (JVM) Java Development Kit (JDK) Benefits.
Getting Started What is Java? A programming language –Fully buzzword-compliant: A simple, object oriented, distributed, interpreted, robust, secure,
CSE 131 Computer Science 1 Module 1: (basics of Java)
IB Computer Science II Paul Bui
BASIC JAVA PROGRAMMING TUTORIAL. History  James Gosling and Sun Microsystems  Oak  Java, May 20, 1995, Sun World  Hot Java –The first Java-enabled.
Lecture 1 Introduction to Java MIT- AITI 2004 What is a Computer Program? For a computer to be able to do anything (multiply, play a song, run a word.
CSC 142 A 1 CSC 142 Introduction to Java [Reading: chapter 0]
CS101: Introduction to Computer Science Slides adapted from Sedgewick and Wayne Copyright © Your First Program.
Java Workshop for Teachers May 6, 2005 A Brief Look at the Java Programming Language.
1 Introduction to Computer Science Spring 2009 Sudhanva Gurumurthi CS 101E.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Programming Languages Machine.
CompSci 100e1.1 Welcome! Program Design and Analysis II for Engineers CompSci 100E French 2231 M, W 2:50-4:05 Professor Jeff Forbes
CS 106 Introduction to Computer Science I 01 / 25 / 2010 Instructor: Michael Eckmann.
1 CSC 201: Computer Programming I B. S. Afolabi. Introduction  3 unit course  2 hours of lecture/week Thursdays 4.00pm – 6.00pm Mondays 4.00pm – 6.00pm.
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.
1 Module Objective & Outline Module Objective: After completing this Module, you will be able to, appreciate java as a programming language, write java.
Java Spring PImage Let’s look at the PImage class in ProcessingPImage –What are the fields (i.e., variables)? –What methods are available? –What.
1.8History of Java Java –Based on C and C++ –Originally developed in early 1991 for intelligent consumer electronic devices Market did not develop, project.
CS 11 java track: lecture 1 Administrivia need a CS cluster account cgi-bin/sysadmin/account_request.cgi need to know UNIX
Introduction to Computer Systems and the Java Programming Language.
Java Programming, Second Edition Chapter One Creating Your First Java Program.
Java means Coffee Java Coffee Beans The name “JAVA” was taken from a cup of coffee.
Clement Allen, PhD Florida A&M University SUMMER 2006.
Netprog: Java Intro1 Crash Course in Java. Netprog: Java Intro2 Why Java? Network Programming in Java is very different than in C/C++ –much more language.
Compiling and the Java Virtual Machine (JVM). The syntax of Pseudocode is pretty loose –visual validation encourages a permissive approach –emphasized.
Software for Translators Barcelona, January 2002.
Working with arrays (we will use an array of double as example)
An Overview of JAVA From basic to slightly less basic Jonathan-Lee Jones.
National Taiwan University Department of Computer Science and Information Engineering National Taiwan University Department of Computer Science and Information.
4-Nov-15 Air Force Institute of Technology Electrical and Computer Engineering Object-Oriented Programming Design Topic 1: The Java Environment Maj Joel.
Recap of Functions. Functions in Java f x y z f (x, y, z) Input Output Algorithm Allows you to clearly separate the tasks in a program. Enables reuse.
JAVA Programming “When you are willing to make sacrifices for a great cause, you will never be alone.” Instructor: รัฐภูมิ เถื่อนถนอม
Lecture 1. Introduction to Programming and Java MIT- AITI 2003.
Core Java Introduction Byju Veedu Ness Technologies httpdownload.oracle.com/javase/tutorial/getStarted/intro/definition.html.
CS101: Introduction to Computer Science Slides adapted from Sedgewick and Wayne Copyright © Your First Java.
CompSci 100e1.1 Welcome! Program Design and Analysis II for Engineers CompSci 100E Soc Psy 126 W, F 2:50-4:05 Professor Jeff Forbes
1.2 Built-in Types of Data Introduction to Programming in Java: An Interdisciplinary Approach · Robert Sedgewick and Kevin Wayne · Copyright © 2008 · December.
CSc 201 Introduction to Java George Wells Room 007, Hamilton Building
CS 106 Introduction to Computer Science I 01 / 22 / 2007 Instructor: Michael Eckmann.
Today… “Hello World” ritual. Brief History of Java & How Java Works. Introduction to Java class structure. But first, next slide shows Java is No. 1 programming.
CHAPTER 1 INTRODUCTION. CHAPTER GOALS To understand the activity of programming To learn about the architecture of computers To learn about machine code.
Introduction to array: why use arrays ?. Motivational example Problem: Write a program that reads in and stores away 5 double numbers After reading in.
Lecture1 Instructor: Amal Hussain ALshardy. Introduce students to the basics of writing software programs including variables, types, arrays, control.
CS 106 Introduction to Computer Science I 01 / 22 / 2008 Instructor: Michael Eckmann.
Computer Science A 1. Course plan Introduction to programming Basic concepts of typical programming languages. Tools: compiler, editor, integrated editor,
CS 177 Recitation Week 1 – Intro to Java. Questions?
ITP 109 Week 2 Trina Gregory Introduction to Java.
Object Oriented Programming Lecture 2: BallWorld.
Sung-Dong Kim, Dept. of Computer Engineering, Hansung University Java - Introduction.
Introduction CMSC 202 Fall Instructors Mr. Ryan Bergeron – Lecture Section 01 Tues/Thu 1:00 – 2:15 am, Sondheim 111 – Lecture Section 04 Tues/Thu.
Introduction of Java Fikri Fadlillah, S.T.
Lecture 1b- Introduction
Chapter No. : 1 Introduction to Java.
CompSci 230 Software Construction
Introduction to Java Dept. Business Computing University of Winnipeg
CS-0401 INTERMEDIATE PROGRAMMING USING JAVA
Introduction to Computer Science I.
General Computer Science for Engineers CISC 106 Lecture 03
Computer Programming-1 CSC 111
Program Design and Analysis II Professor: Jeffrey Forbes
Presentation transcript:

1.1 Your First Program Introduction to Programming in Java: An Interdisciplinary Approach · Robert Sedgewick and Kevin Wayne · Copyright © 2008 · October 13, :23 tt

2 Why Programming? Idealized computer. "Please simulate the motion of a system of N heavenly bodies, subject to Newton's laws of motion and gravity." Prepackaged software solutions. Great, if it does exactly what you need. Computer programming. Art of making a computer do what you want. Ada Lovelace Analytic Engine

3 Languages Machine languages. Tedious and error-prone. Natural languages. Ambiguous and hard for computer to parse. High-level programming languages. Acceptable tradeoff. [ real newspaper headlines, compiled by Rich Pattis ] Kids Make Nutritious Snacks. Red Tape Holds Up New Bridge. Police Squad Helps Dog Bite Victim. Local High School Dropouts Cut in Half. “Instead of imagining that our main task is to instruct a computer what to do, let us concentrate rather on explaining to human beings what we want a computer to do.” – Donald Knuth

4 Why Java? Java features. n Widely used. n Widely available. n Embraces full set of modern abstractions. n Variety of automatic checks for mistakes in programs. Java economy. n Mars rover. n Cell phones. n Blu-ray Disc. n Web servers. n Medical devices. n Supercomputing. n … James Gosling $100 billion, 5 million developers

5 Why Java? Java features. n Widely used. n Widely available. n Embraces full set of modern abstractions. n Variety of automatic checks for mistakes in programs. Caveat. “There are only two kinds of programming languages: those people always [gripe] about and those nobody uses.” – Bjarne Stroustrup

6 Why Java? Java features. n Widely used. n Widely available. n Embraces full set of modern abstractions. n Variety of automatic checks for mistakes in programs. Caveat. No perfect language. Our approach. n Minimal subset of Java. n Develop general programming skills that are applicable to: C, C++, C#, Perl, Python, Ruby, Matlab, Fortran, Fortress, …

7 A Rich Subset of the Java Language Primitive Numeric Types != ==>=<= <>-- / + % - ++ * Integer.parseInt() Double.parseDouble() Parsing Math.max()Math.min() Math.pow()Math.sqrt() Math.PIMath.abs() Math.log() Math.sin() Math Library Math.exp() Math.cos()System.out.println() System.out.print() System.out.printf() System for if Flow Control while else ! || true Boolean && false ;, ( { Punctuation ) } a[i] new a.length Arrays matches()charAt() length() + String compareTo() "" booleanchar long int Built-In Types String double equals()toString() main()new public class Objects private static = Assignment

Create, Compile, Execute

9 Programming in Java Programming in Java. Create the program by typing it into a text editor, and save it as HelloWorld.java HelloWorld.java /******************************************* * Prints "Hello, World" * Everyone's first Java program. *******************************************/ public class HelloWorld { public static void main(String[] args) { System.out.println("Hello, World"); }

10 Programming in Java Programming in Java. Create the program by typing it into a text editor, and save it as HelloWorld.java Compile it by typing at the command-line: javac HelloWorld.java This creates a Java bytecode file named: HelloWorld.class command-line % javac HelloWorld.java (or click the Compile button in DrJava)

11 Programming in Java Programming in Java. Create the program by typing it into a text editor, and save it as HelloWorld.java Compile it by typing at the command-line: javac HelloWorld.java Execute it by typing at the command-line: java HelloWorld % javac HelloWorld.java % java HelloWorld Hello, World command-line (or click the Run button in DrJava) 1.2

Dr. Java

13 Dr. Java compile

14 Dr. Java command-line argument

1.1 Extra Slides

16 Java Features Java is: n Object oriented. n Statically typed. n Architecture neutral. n Multi-threaded. n Garbage-collecting. n Robust. n Small. n Simple. n Fast. n Secure. n Extensible. n Well-understood. n Fun. Don't believe anything on this slide! Make up your own mind. Java is: n Not new. n Designed for toasters. n Not done yet. n Not as useful as C, C++, FORTRAN. n Slow. n Unsafe. n Huge. n Complex.

17 Java Bytecode \0 \0 \0. \0 035 \n \0 006 \0 017 \t \0 020 \0 021 \b \0 022 \n \0 023 \ \ \ \ \0 003 ( ) V 001 \0 004 C o d e 001 \0 017 L i n e N u m b e r T a b l e 001 \0 004 m a i n 001 \0 026 ( [ L j a v a / l a n g / S t r i n g ; ) V 001 \0 \n S o u r c e F i l e 001 \0 017 H e l l o W o r l d. j a v a \f \0 007 \0 \b 007 \ \f \0 030 \ \0 \f H e l l o, W o r l d 007 \0 032 \f \0 033 \ \0 \n H e l l o W o r l d 001 \0 020 j a v a / l a n g / O b j e c t 001 \ j a v a / l a n g / S y s t e m \0 003 o u t 001 \0 025 L j a v a / i o / P r i n t S t r e a m ; 001 \ j a v a / i o / P r i n t S t r e a m 001 \0 007 p r i n t l n 001 \ ( L j a v a / l a n g / S t r i n g ; ) V \0 ! \0 005 \0 006 \0 \0 \0 \ \0 002 \0 001 \0 007 \0 \b \0 001 \0 \t \0 \0 \ \0 001 \0 001 \0 \0 \0 005 * 267 \ \0 \0 \ \0 \n \0 \0 \0 006 \0 001 \0 \0 \0 \f \0 \t \ \0 \f \0 001 \0 \t \0 \0 \0 % \0 002 \0 001 \ \0 \0 \t 262 \ \ \0 \0 \ \0 \n \0 \0 \0 \n \0 002 \0 \0 \0 017 \0 \b \ \0 001 \0 \r \0 \0 \0 002 \ HelloWorld.class