BA22001 Introduction to Java Instructor: Jingwu He.

Slides:



Advertisements
Similar presentations
1 Copyright © 2005, Oracle. All rights reserved. Introducing the Java and Oracle Platforms.
Advertisements

Liang, Introduction to Java Programming, Sixth Edition, (c) 2005 Pearson Education, Inc. All rights reserved Chapter 1 Introduction to.
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
IC211 Object Oriented Programming Overview of Java.
Java: History and Introduction (Lecture # 1). History… Java – Based on C and C++ – Developed in 1991 for intelligent consumer electronic devices – Green.
Introduction to Java Kiyeol Ryu Java Programming Language.
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, 4E
For more Lectures and Notes Visit
Introduction to Java.
CSE 1301 J Lecture 2 Intro to Java Programming Richard Gesick.
L EC. 01: J AVA FUNDAMENTALS Fall Java Programming.
01 Introduction to Java Technology. 2 Contents History of Java What is Java? Java Platforms Java Virtual Machine (JVM) Java Development Kit (JDK) Benefits.
LESSON 1 INTRODUCTION Compiled By: Edwin O. Okech [Tutor, Amoud University] JAVA PROGRAMMING.
Java PAL.  Contains the development kit and the runtime environment ( aka the Java Virtual Machine )  Download Link:
CMSC 202 Computer Science II for Majors Fall 2009 Introduction.
Getting Started What is Java? A programming language –Fully buzzword-compliant: A simple, object oriented, distributed, interpreted, robust, secure,
BASIC JAVA PROGRAMMING TUTORIAL. History  James Gosling and Sun Microsystems  Oak  Java, May 20, 1995, Sun World  Hot Java –The first Java-enabled.
Chapter 1 Coding Introduction.
+ Java vs. Javascript Jessi Style. + Java Compiled Can stand on its own Written once, run anywhere Two-stage debugging Java is an Object Oriented Programming.
S.W. Ma/CIM/LWL41211/2 Prog. IIA Page 1 HKIVE (Lee Wai Lee Campus) Department of CIM Course : Year 2 Module : Programming IIA Textbook : Introduction.
CSCI 224 Introduction to Java Programming. Course Objectives  Learn the Java programming language: Syntax, Idioms Patterns, Styles  Become comfortable.
CMSC 202 Computer Science II for Majors Object-Oriented Programming.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Programming Languages Machine.
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved Chapter 1 Introduction to Computers,
CPCS  Problem Solving in Everyday Life  Types of Problems  Problem Solving with Computers  Difficulties with Problem Solving 0-3.
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved Chapter 1 Introduction to Programs,
Java Introduction Lecture 1. Java Powerful, object-oriented language Free SDK and many resources at
1 Module Objective & Outline Module Objective: After completing this Module, you will be able to, appreciate java as a programming language, write java.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Chapter 1 Introduction to.
© 2012 Pearson Education, Inc. All rights reserved. 1-1 Why Java? Needed program portability – Program written in a language that would run on various.
Chapter 1: Introduction to Programs, and Java 1. Objectives To review programs (§ ). To understand the relationship between Java and the World Wide.
Java Introduction 1. Introduction to Java Programming2 Computers and Computer Languages Computers are everywhere –how many computers do you own? Computers.
Introduction to Java Programming with Forte Y. Daniel Liang.
Introduction to Java Programming. Introduction Course Objectives Organization of the Book.
National Taiwan University Department of Computer Science and Information Engineering National Taiwan University Department of Computer Science and Information.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Chapter 1 Introduction to.
J ava P rogramming: From Problem Analysis to Program Design, From Problem Analysis to Program Design, Second Edition Second Edition D.S. Malik D.S. Malik.
Java Basics 1 Brief History of Java and Overview of Langauge.
Application Architecture Using Java Hong Li. Introduction Developed by a team led by James Gosling at Sun Microsystem. Originally called Oak, designed.
Liang, Introduction to Java Programming, Seventh Edition, (c) 2009 Pearson Education, Inc. All rights reserved Chapter 1 Introduction to.
© 2012 Pearson Education, Inc. All rights reserved types of Java programs Application – Stand-alone program (run without a web browser) – Relaxed.
Introduction to Java Programming. 2 Chapter 1 Introduction to Java and Forte F What Is Java? F Getting Started With Java Programming –Create, Compile.
©2016 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. CSC 110 – INTRO TO COMPUTING - PROGRAMMING Overview of Programming.
1 Introduction to Java. 2 * 10% Assignments/ class participation * 10% Pop Quizzes * 05% Attendance * 25% Mid Term * 50% Final Term.
ITP 109 Week 2 Trina Gregory Introduction to Java.
Introduction to Programming 1 1 2Introduction to Java.
Liang, Introduction to Java Programming, Ninth Edition, (c) 2013 Pearson Education, Inc. All rights reserved. 1 Chapter 1 Introduction.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Chapter 1 Introduction to Computers,
Introduction to JAVA Programming
Introduction to Java Programming, 4E Y. Daniel Liang.
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.
Fundamental of Java Programming (630002) Unit – 1 Introduction to Java.
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.
Chapter 1 Coding Introduction.
Java™ 2 Platform Getting Started.
Before You Begin Nahla Abuel-ola /WIT.
Chapter 1 Introduction to Computers, Programs, and Java
Java programming lecture one
Chapter 1 Coding Introduction.
(Computer fundamental Lab)
Java History, Editions, Version Features
Introducing Java.
Chap 1. Getting Started Objectives
Chap 4. Programming Fundamentals
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:

BA22001 Introduction to Java Instructor: Jingwu He

BA22002 History of Java In 1991, Sun started development of a programming language that should be used for programming of consumer electronics, e.g. Mobile telephones, remote console,... The language was originally named Oak by James Gosling, the creator of the language. The market was not ready for this language and the project goal was changed: the language should be for the web. The browser HotJava was launched in The browser was written in Java and could execute applets (code running inside web-pages) Also in 1995 Netscape decided to make their webbrowser Java enabled.

BA22003 More History The first versions of the language (e.g. Java 1.02 released 1996) was not ready for industry use, they were to immature (e.g. when it comes to making user interface). In December 1996 a much more mature version Java 1.1 was release. (some browser has build in support for JDK and not later versions).

BA22004 è Full application programming language è Additional capability as a Web programming language è OO programming language è Adopts its looks from C++ è Compiled to processor-neutral instruction set then interpreted on each supporting platform è Extremely fast adoption rate! What is Java

BA22005 Terminology è Package A grouping of logically related code (classes). For instance, all user-interface code is in a single package; likewise, all input/output code and all network code. è Class A collection of data and methods that operate on that data. è Method A group of statements in a class that handle a task. è Bytecodes A set of instructions that look like machine code, but are not specific to any processor. è Virtual Machine The environment in which Java runs. The JVM is responsible for executing the bytecodes and has responsibility for the fundamental capabilities of Java.

BA22006 Any Operating System JAVA Application (Bytecodes) JAVA Virtual Machine Any Hardware Platform Java Architecture

BA22007 Platform Independence Java source Java compile Java bytecode -HelloWorld.class -Platform Neutral Java source compiled into intermediary bytecode n Application runs anywhere Java VM is ported n Applet runs in any Java enabled browser test suite class HelloWorld { public static void Main (String args[]){ System.out.println("Hello World"); } javac HelloWorld.java

BA22008 Java Program Patterns Applications –Java programs which run stand alone Web-based Java Applications –Applets Dynamic and interactive programs that can run inside a web page displayed by a browser enabled for Java –Servlets Programs that run inside request/response oriented servers –JavaServer Pages An extension to the servlet architecture. Allow for the separation of the display of web content and the generation of that content

BA22009 Java 2 Platform Editions J2MEJ2EEJ2SE

BA Java 2 Platform Editions –Java 2 Platform, Micro Edition (J2ME) Highly optimized runtime environment Targets consumer products –Pagers, cell phones –Java 2 Platform, Standard Edition (J2SE) Java 2 tools, runtimes, and APIs for developers writing, deploying, and running applets and applications Referred to as Java 2 SDK –Java 2 Platform, Enterprise Edition (J2EE) Targets enterprise-class server-side applications.

BA Object Oriented Programming Conceptualizing a computer program as a set of separate objects that interact with each other. Objects can model real life situations –BankAccount object –Bicycle Objects contain information and the means of accessing and changing that information. Benefits –Reusability –Reliability

BA Class A template for creating objects l A class is a blueprint, or prototype, that defines the variables and the methods common to all objects of a certain kind

BA Working with Objects method data message anObject data encapsulation

BA Bank Account Class name address balance interestRate ytdInterest deposit withdraw changeAddress attributes (variables) methods

BA Instance of a class (object) name address balance interestRate ytdInterest deposit withdraw changeAddress class name address balance interestRate ytdInterest deposit withdraw changeAddress Instance of a class (object) John Smith 1234 Main St new

BA Many instances of a class (objects) name address balance interestRate ytdInterest deposit withdraw changeAddress Instance of a class (object) John Smith 1234 Main St name address balance interestRate ytdInterest deposit withdraw changeAddress Mary Smith 2115 Pine St Instance of a class (object)

BA Messages trigger methods name address balance interestRate ytdInterest deposit withdraw changeAddress Mary Smith 2115 Pine St Instance of a class

BA Bicycles

BA Bicycle Class color currentGear currentSpeed currentCadence numberOfGears brake changeGear changeCadence attributes (variables) methods

BA An instance of a class (object)

BA Many instances (objects)

BA Messages

BA How does in work in Java? Class contains: –Variables To hold values –Methods To execute logic

BA Java Program naming conventions Classes –Start with upper case alphabetic –Must be stored in a file with the same name and a.java extension –Use meaningful names –Examples BankAccount – good Bike - good 113BankAccount – invalid bankAccount – works, but may get a warning Stuff - works, but not meaningful

BA Java Program naming conventions methods –Start with lower case alphabetic –Use meaningful names –Capitalize words –Examples calculateInterest – good changeSpeed - good 123Calculate – invalid CalculateInterest – works, but may get a warning stuff - works, but not meaningful

BA Java Program naming conventions variables –Start with lower case alphabetic, _ or $ –Use meaningful names –Capitalize words –Examples int areaCode – good int currentSpeed - good boolean 123 – invalid float CalculatedInterest – works, but doesn’t follow convention int stuff - works, but not meaningful

BA class MyClass { class variables myMethod1() { method variables statement 1; statement 2; } myMethod2() { method variables statement 1; statement 2; } Java Program structure scope

BA class BankAccount { String name; String address; float balance; float interestRate; changeAddress() { method variables statement 1; statement 2; } withdraw() { method variables statement 1; statement 2; } deposit() { method variables statement 1; statement 2; } Java Program structure BankAccount myAccount = new BankAccount();

BA class Bike { int currentSpeed; int currentCadence; int numberOfGears; int currentGear; changeGears() { method variables statement 1; statement 2; } changeSpeed() { method variables statement 1; statement 2; } brake() { method variables statement 1; statement 2; } Java Program structure

BA Creating Objects new operator –Creates an instance of class (object) Bike myBike = new Bike() –Allocates memory Deallocating objects –Done by Java garbage collection

BA Working with Objects changeSpeed status speed myBike

BA Java Programming H SDK H Java Software Development Toolkit H Available from Sun Microsystems, Inc. H SDK 1.4 is the current version H Also version 5.0 RC (Released Code) H Known as JDK in early versions H Development environments (IDE) H IBM - WebSphere Studio Application Developer H Sun - Forte H Microsoft - Visual J++ H Borland - JBuilder H Oracle - JDeveloper H And others

BA Java Translation Enter/edit the Java program Save Source Compiler Java Bytecode Success Fail Correct errors.java file Java Java Bytecode Interpreter Machine Language Instructions CPU Execution of Machine Language Instructions Data for the Program Program Output.class file JVM Syntax errors Logic errors