ITP 109 Week 2 Trina Gregory Introduction to Java.

Slides:



Advertisements
Similar presentations
What is a Computer Program? For a computer to be able to do anything (multiply, play a song, run a word processor), it must be given the instructions.
Advertisements

Programming for Beginners
JAVA Programming Environment © Juhani Välimäki 2003.
Introduction To Java Objectives For Today â Introduction To Java â The Java Platform & The (JVM) Java Virtual Machine â Core Java (API) Application Programming.
JAVA BASICS SYNTAX, ERRORS, AND DEBUGGING. OBJECTIVES FOR THIS UNIT Upon completion of this unit, you should be able to: Explain the Java virtual machine.
Your First Java Program: HelloWorld.java
Introduction to Java The objectives of this chapter are: To describe the key aspects of Java To describe the Java software development kit (SDK) To explain.
Object Orientated Programming
1 Fall 2008ACS-1903 Chapter 1 Topics Java History Java Programs Why Program? Computer Systems: Hardware and Software Programming Languages What Is a Program.
Introduction to Java Programming
1 Programming Languages Translation  Lecture Objectives:  Be able to list and explain five features of the Java programming language.  Be able to explain.
Introduction to Java.
01 Introduction to Java Technology. 2 Contents History of Java What is Java? Java Platforms Java Virtual Machine (JVM) Java Development Kit (JDK) Benefits.
Advanced OOP MCS-3 OOP BSCS-3 Lecture # 1
Introduction to Java Programming. Contents 1. Java, etc. 2. Java's Advantages 3. Java's Disadvantages 4. Types of Java Code 5. Java Bytecodes 6. Steps.
IB Computer Science II Paul Bui
Introducing Java.
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.
CSCI 224 Introduction to Java Programming. Course Objectives  Learn the Java programming language: Syntax, Idioms Patterns, Styles  Become comfortable.
Chapter 1: Creating Java Programs
CMSC 202 Computer Science II for Majors Object-Oriented Programming.
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.
Java Lecture 16: Dolores Zage. WWW n Was a method for distributing passive information n added forms and image maps n interaction was only a new way to.
1.  At the end of this slide, student can:  Explore tools, features, properties and interface of the Textpad.  Creating a new project.  Open and run.
Session One Introduction. Personal Introduction Role of programmers Robot Examination HUD & HID Uploading Code.
Lecture 1 Introduction to Java MIT-AITI Ethiopia 2004.
1 Module Objective & Outline Module Objective: After completing this Module, you will be able to, appreciate java as a programming language, write java.
CS 11 java track: lecture 1 Administrivia need a CS cluster account cgi-bin/sysadmin/account_request.cgi need to know UNIX
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Chapter 1 Introduction to.
Jaeki Song ISQS6337 JAVA Lecture 03 Introduction to Java -The First Java Application-
© 2012 Pearson Education, Inc. All rights reserved. 1-1 Why Java? Needed program portability – Program written in a language that would run on various.
POS 406 Java Technology And Beginning Java Code
Board Activity Find your seat on the seating chart Login – Remember your login is your first initial your last name and the last three numbers of your.
Programming Concept Chapter I Introduction to Java Programming.
Week 1 - Friday.  What did we talk about last time?  Our first Java program.
Fall 2006Slides adapted from Java Concepts companion slides1 Introduction Advanced Programming ICOM 4015 Lecture 1 Reading: Java Concepts Chapter 1.
Object Oriented Programming Lecture 3. Introduction  In discussing Java, some items need to be clarified  The Java programming language  The Java virtual.
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.
JAVA Programming “When you are willing to make sacrifices for a great cause, you will never be alone.” Instructor: รัฐภูมิ เถื่อนถนอม
© 2012 Pearson Education, Inc. All rights reserved types of Java programs Application – Stand-alone program (run without a web browser) – Relaxed.
introductory lecture on java programming
©2016 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. CSC 110 – INTRO TO COMPUTING - PROGRAMMING Overview of Programming.
CSCI 212 Object-Oriented Programming in Java. Prerequisite: CSCI 111 variable assignment statement while loop for loop post-increment (i++) strong typing.
3/5/2002e-business and Information Systems1 Java Java Java Virtual Machine (JVM) Java Application Program Interface (API) HW Kernel API Application Programs.
CS 177 Recitation Week 1 – Intro to Java. Questions?
Introduction to Programming 1 1 2Introduction to Java.
Java Programming Fifth Edition Chapter 1 Creating Your First Java Classes.
Introduction to JAVA Programming
Introduction to 1. What is Java ? Sun Microsystems Java is a programming language and computing platform first released by Sun Microsystems in The.
SESSION 1 Introduction in Java. Objectives Introduce classes and objects Starting with Java Introduce JDK Writing a simple Java program Using comments.
Sung-Dong Kim, Dept. of Computer Engineering, Hansung University Java - Introduction.
Introduction to Algorithm. What is Algorithm? an algorithm is any well-defined computational procedure that takes some value, or set of values, as input.
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.
CS-140 Dick Steflik Lecture 3. Java C++ Interpreted optimized for the internet Runs on virtual ized machine Derived from C++ Good object model Widely.
Computer Programming Your First Java Program: HelloWorld.java.
Lecture 1b- Introduction
Before You Begin Nahla Abuel-ola /WIT.
Chapter 1 Introduction to Computers, Programs, and Java
Introduction to.
Java programming lecture one
Introduction to Java Dept. Business Computing University of Winnipeg
Getting Started ARCS Lab..
Introduction CSC 111.
(Computer fundamental Lab)
IB Computer Science II Paul Bui
Chap 1. Getting Started Objectives
Computer Programming-1 CSC 111
Review of Previous Lesson
Outcome of the Lecture Upon completion of this lecture you will be able to understand Fundamentals and Characteristics of Java Language Basic Terminology.
Presentation transcript:

ITP 109 Week 2 Trina Gregory Introduction to Java

2 Overview Recap of last lecture Basic computer components Different ways of writing and running programs –Compiled –Interpreted Java –How does it work

3 Recap Java – object-oriented programming language 3 different platforms for Java –Standard (J2SE) –Enterprise (J2EE) –Mobile (J2ME) Features of Java –Small, simple, easy to compile, powerful & flexible

4 Benefits of Java Object-oriented Improved on C++ Security APIs (Application Programming Interface) –Lots of prewritten code Distributed –Able to run over the network “Write once, run anywhere” –Platform independent

5 Java Programs Application –Runs natively on the system through the Java Virtual Machine (JVM) Applet –Runs in a browser –Does smaller tasks Programs –Both applets and applications are “Java programs”

6 Basic Computer Components Hardware –CPU, memory, secondary storage Operating System –Windows, Mac OS, Linux, Unix Applications –MS Office, Adobe Suite (Photoshop), games, web browsers, Eclipse

7 What programs need to communicate? Platform –Windows, Mac, Linux, etc. –Each platform recognizes a different format for running programs Windows – Executable (.exe) Mac – Universal Binary –Executable programs written for a Windows computer will not work on a Linux system In addition, processors on each different computer category speak a different kind of machine language –Typically, we don’t need to worry about this because the operating system takes care of it

8 2 Solutions to Program Development Compiled –Communicates with only one kind of computer Interpreted –Communicates with any kind of computer

9 Complied Programs

10 Compiled Programs They are reasonably fast Compiling also checks for errors The compiled code is platform specific Programmers have to produce a different version for each platform they want to run on

11 Interpreted Programs

12 Interpreted Programs Cross Platform –Only need to write the program once for all platforms Slow –Error checking and interpreting

13 How does Java work? Uses compiling and interpretation A little slower, but runs on any operating system Compiles source code to bytecode Uses Java Virtual Machine (JVM) to interpret bytecode Different operating system has different JVM –Typically, the JVM is written in C

14 How Java Works

15 Java Terminology Java Virtual Machine (JVM) Java Runtime Environment (JRE) Application Programming Interface (API) –Consists of pre-written code that you can use –Example: DirectX, OpenGL Java Developers Kit (JDK) –Old name for Java technology Java 2, Java 2 platform, Java 2 SDK –New name for Java technology

16 Java Terminology JVM JRE Java SDK

17 Java API Documentation Detailed information about API Extremely valuable resource

Your First Java Program Hello World –Traditionally your first computer program –Originates from the first C programming text What does HelloWorld.java look like? class HelloWorld { public static void main(String[] args) { System.out.println("Hello World!"); } class HelloWorld { public static void main(String[] args) { System.out.println("Hello World!"); } 18

Hello World - Breakdown class HelloWorld –This specifies the class name. –Everything in Java is part of a class. –We will learn more about classes in a later lecture. –Everything between the curly braces { and } belongs to the class. public static void main (String[] args) –Every Java application must have these lines. These lines tell the compiler that this is the start of the program. System.out.println("Hello World"); –This says to the compiler “I want to print the exact words Hello World”. –The semi-colon ; is the end of a statement. Think of it like a period in the English language. 19

Comments A comment can begin with //. Everything after these symbols and to the end of the line is treated as a comment and is ignored by the compiler. class HelloWorld { // My first program public static void main(String[] args) { // Print out the words - Hello World System.out.println("Hello World!"); } class HelloWorld { // My first program public static void main(String[] args) { // Print out the words - Hello World System.out.println("Hello World!"); }

Comments A comment can begin with /* and end with */ Everything between these symbols is treated as a comment and is ignored by the compiler. /* Hello World by Trina Gregory */ class HelloWorld { public static void main(String[] args) { System.out.println("Hello World!"); } /* Hello World by Trina Gregory */ class HelloWorld { public static void main(String[] args) { System.out.println("Hello World!"); }

Comments A javadoc comment, begins with /** and ends with */. It can be extracted automatically from Java software. /** * Hello World program Trina Gregory */ class HelloWorld { public static void main(String[] args) { System.out.println("Hello World!"); } /** * Hello World program Trina Gregory */ class HelloWorld { public static void main(String[] args) { System.out.println("Hello World!"); }

When to Use Comments Begin each program file with an explanatory comment –What the program does –The name of the author (YOU) –Contact information for the author ( ) –Date of creation or the last modification Provide only those comments which the expected reader of the program file will need in order to understand it.

Example 24 /* * Trina Gregory, * ITP 109 Fall 2011, 8/30/2011 * HelloWorld program */ class HelloWorld { public static void main(String[] args) { System.out.println("Hello World!"); } /* * Trina Gregory, * ITP 109 Fall 2011, 8/30/2011 * HelloWorld program */ class HelloWorld { public static void main(String[] args) { System.out.println("Hello World!"); }

25 Bugs and Debugging Bugs: –Program does not compile –Program produces output that is not expected when it executes Debugging is the act of removing them A programmer spends about half of his/her time debugging code Compiler error Executing (or run-time) error