11 January 2013Birkbeck College, U. London1 Introduction to Programming Lecturer: Steve Maybank Department of Computer Science and Information Systems.

Slides:



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

Foundations of Programming and Problem Solving Introduction.
Introduction to Programming Java Lab 1: My First Program 11 January JavaLab1.ppt Ping Brennan
Research Methods Lecturer: Steve Maybank
8 October 2013Birkbeck College, U. London1 Introduction to Computer Systems Department of Computer Science and Information Systems Autumn 2013 Preliminary.
22 February 2013Birkbeck College, U. London1 Introduction to Programming Lecturer: Steve Maybank Department of Computer Science and Information Systems.
18 January 2013Birkbeck College, U. London1 Introduction to Programming Lecturer: Steve Maybank Department of Computer Science and Information Systems.
8 October 2013Birkbeck College, U. London1 Introduction to Computer Systems Lecturer: Steve Maybank Department of Computer Science and Information Systems.
Introduction to Computer Systems
15 February 2013Birkbeck College, U. London1 Introduction to Programming Lecturer: Steve Maybank Department of Computer Science and Information Systems.
1 March 2013Birkbeck College, U. London1 Introduction to Programming Lecturer: Steve Maybank Department of Computer Science and Information Systems
8 October 2013Birkbeck College, U. London1 Introduction to Computer Systems Lecturer: Steve Maybank Department of Computer Science and Information Systems.
8 March 2013Birkbeck College, U. London1 Introduction to Programming Lecturer: Steve Maybank Department of Computer Science and Information Systems
15 October 2013Birkbeck College, U. London1 Introduction to Computer Systems Lecturer: Steve Maybank Department of Computer Science and Information Systems.
Introduction to Programming
25 March 2013Birkbeck College, U. London1 Introduction to Programming Lecturer: Steve Maybank Department of Computer Science and Information Systems
8 February 2013Birkbeck College, U. London1 Introduction to Programming Lecturer: Steve Maybank Department of Computer Science and Information Systems.
18 January 2013Birkbeck College, U. London1 Introduction to Programming Lecturer: Steve Maybank Department of Computer Science and Information Systems.
25 January 2013Birkbeck College, U. London1 Introduction to Programming Lecturer: Steve Maybank Department of Computer Science and Information Systems.
29 October 2013Birkbeck College, U. London1 Introduction to Computer Systems Lecturer: Steve Maybank Department of Computer Science and Information Systems.
Introduction to Computer Systems
INTRODUCTION Chapter 1 1. Java CPSC 1100 University of Tennessee at Chattanooga 2  Difference between Visual Logic & Java  Lots  Visual Logic Flowcharts.
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.
1 Fall 2008ACS-1903 Chapter 1 Topics Java History Java Programs Why Program? Computer Systems: Hardware and Software Programming Languages What Is a Program.
CHAPTER 1 INTRODUCTION GOALS  To understand the activity of programming  To learn about the architecture of computers  To learn about machine code and.
1 SD1042: Introduction to Software Development SD1042 Introduction to Software Development SCHOOL OF COMPUTING AND TECHNOLOGY Getting Started MODULE TEAM.
CSC 142 A 1 CSC 142 Introduction to Java [Reading: chapter 0]
Chapter 2 How to Compile and Execute a Simple Program.
Sadegh Aliakbary Sharif University of Technology Spring 2011.
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.
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.
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.
Chapter 1: Introducing JAVA. 2 Introduction Why JAVA Applets and Server Side Programming Very rich GUI libraries Portability (machine independence) A.
Introduction to Programming David Goldschmidt, Ph.D. Computer Science The College of Saint Rose Java Fundamentals (Comments, Variables, etc.)
CS 11 java track: lecture 1 Administrivia need a CS cluster account cgi-bin/sysadmin/account_request.cgi need to know UNIX
© 2012 Pearson Education, Inc. All rights reserved. 1-1 Why Java? Needed program portability – Program written in a language that would run on various.
Programming Concept Chapter I Introduction to Java 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 ( ปรับปรุง )
CHAPTER 3 GC Java Fundamentals. 2 BASICS OF JAVA ENVIRONMENT  The environment  The language  Java applications programming Interface API  Various.
Chapter 1 Section 1.1 Introduction to Java Slides prepared by Rose Williams, Binghamton University Kenrick Mock, University of Alaska Anchorage.
CHAPTER 1 INTRODUCTION. CHAPTER GOALS To understand the activity of programming To understand the activity of programming To learn about the architecture.
Introduction To JAVA By Ihtesham Ul Haq. Course Objectives Upon completing the course, you will understand Upon completing the course, you will understand.
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.
© 2004 Pearson Addison-Wesley. All rights reserved ComS 207: Programming I Instructor: Alexander Stoytchev
INM205 Object Oriented Programming in JAVA Dr. Michael Casey Department of Computing.
Chapter 1 Introduction. Chapter Goals To understand the activity of programming To learn about the architecture of computers To learn about machine code.
8 January 2016Birkbeck College, U. London1 Introduction to Programming Lecturer: Steve Maybank Department of Computer Science and Information Systems
© 2012 Pearson Education, Inc. All rights reserved types of Java programs Application – Stand-alone program (run without a web browser) – Relaxed.
Creating a Java Application and Applet
CHAPTER 1 INTRODUCTION. CHAPTER GOALS To understand the activity of programming To learn about the architecture of computers To learn about machine code.
Execution ways of program References: www. en.wikipedia.org/wiki/Integrated_development_environment  You can execute or run a simple java program with.
SESSION 1 Introduction in Java. Objectives Introduce classes and objects Starting with Java Introduce JDK Writing a simple Java program Using comments.
Copyright 2010 by Pearson Education APCS Building Java Programs Chapter 1 Lecture 1-1: Introduction; Basic Java Programs reading:
Introduction to Programming
John Woodward A Simple Program – Hello world
GC101 Introduction to computer and program
Chapter 1 – Introduction
Introduction to Programming
Java programming lecture one
Introduction to Programming
Introduction to Programming
Introduction to Programming
Introduction to Programming
CSE 142, Spring 2012 Building Java Programs Chapter 1
Computer Programming-1 CSC 111
Instructor: Alexander Stoytchev
Presentation transcript:

11 January 2013Birkbeck College, U. London1 Introduction to Programming Lecturer: Steve Maybank Department of Computer Science and Information Systems Spring 2013 Week 1: First Program

Module Information Time: on Fridays in the spring term. A-K: lectures to lab sessions to L-Z: lab sessions to lectures to Week 11: in lab test. 11 January 2013Birkbeck College, U. London2

Assessment In Lab test: 30% Two hour examination in summer 2013: 70% The mock examination and the mock in Lab test do not contribute to the marks. 11 January 2013Birkbeck College, U. London3

Essential Text Book Cay Horstmann (2013) Java for Everyone, Wiley, 2 nd edition. This module draws on the first six chapters of JFE. The lab classes are based on exercises suggested in JFE. 11 January 2013Birkbeck College, U. London4

Syllabus First program Safe operation of computing equipment Variables and number types String types Arithmetic and Boolean operations If statement Loops Methods Arrays 11 January 2013Birkbeck College, U. London5

This Lecture Based on Ch. 1 of JFE Aim 1: provide background information on computing Aim 2: provide enough information to write a first Java program. 11 January 2013Birkbeck College, U. London6

Structure of a Computer Central Processing Unit: executes instructions. Main memory (= primary storage): stores programs and data ready for the CPU. Bus: connects the CPU and the main memory. 11 January 2013Birkbeck College, U. London7 CPU Main memory

Problem The CPU of a computer is designed to carry out a fixed set of simple instructions. It takes too much time to write programs using these instructions. 11 January 2013Birkbeck College, U. London8

Solution Write programs in a special high level programming language. Then use another program (a compiler) to convert each high level program into a list of instructions for the CPU. 11 January 2013Birkbeck College, U. London9

Java First version developed in 1991 by James Gosling and Patrick Naughton for use in consumer products, eg. set top boxes. Java based browser presented in 1995 at the SunWorld exhibition. A browser can run Java code (applets) obtained from anywhere on the Internet. 11 January 2013Birkbeck College, U. London10

Advantages of Java Portable: the same Java program can be run without change on Windows, UNIX, Linux or Macintosh. Safe: a browser can run a Java program without endangering the PC running the browser. Very large libraries for graphics, user interface, cryptography, networking, etc. 11 January 2013Birkbeck College, U. London11

Java Portability The Java compiler converts a Java program to Java byte code. The Java byte code is executed by a Java Virtual Machine. The JVM is not portable: different JVMs are needed for different platforms. The Java program is portable given the right JVM. 11 January 2013Birkbeck College, U. London12

Integrated Development Environment The IDE for Java is BlueJ BlueJ facilities for Java programs: Edit Compile Run See practical session. 11 January 2013Birkbeck College, U. London13

BlueJ Console Window 11 January 2013Birkbeck College, U. London14 See

Classes, Objects and Methods A class describes a set of objects with the same behaviour. An object consists of data, together with methods which act on the data in that object. A method is a sequence of instructions with a name. 11 January 2013Birkbeck College, U. London15

The String Class Objects (string literals): Hello, World. Methods: the object Hello contains methods length() and substring() which act on the data in Hello: Hello.length(); // 5 Hello.substring(0, 2); // He 11 January 2013Birkbeck College, U. London16

Java Programs Java programs consist of classes. When a Java program runs, objects are created and the methods act on the data in the objects. Exception: a static method can be used without any associated object. 11 January 2013Birkbeck College, U. London17

My First Program public class HelloPrinter { public static void main(String[] args) { System.out.println(Hello, World!); } 11 January 2013Birkbeck College, U. London18

Commentary 1 MFP contains a single class: HelloPrinter The class has no associated objects. The class contains one method, main(), which can be invoked without first creating any object. 11 January 2013Birkbeck College, U. London19

Commentary 2 public class: HelloPrinter and main() are available to any user static: main() can be invoked without any associated object. void: no value is returned by main(). public, class, static, void are reserved words. 11 January 2013Birkbeck College, U. London20

System.out.println(Hello) System.out is an object println() is a method which is applied to data in System.out. The string Hello is a parameter for the method println(). Note how the details of System.out are hidden from the user. This is an example of encapsulation. 11 January 2013Birkbeck College, U. London21

Java Syntax Braces (brackets) occur in matching pairs, {…}. Every statement must end in a semicolon. Upper case and lower case are distinguished. Every Java application must have a main method. Reserved words cannot be used for other purposes. A method can have any number of parameters, including none. 11 January 2013Birkbeck College, U. London22

String Concatenation Hello, +World! produces Hello, World! Hello+7 produces Hello7 (The number 7 is converted to a string.) Similarly, 7+Hello produces 7Hello 7+7 produces January 2013Birkbeck College, U. London23

Escape Sequences On printing He said \Hello\ the result is He said Hello The pair \ is an escape sequence. The escape sequence \n denotes new line, for example System.out.print(*\n**\n); produces * ** 11 January 2013Birkbeck College, U. London24