Introduction to Java Programming, 4E Y. Daniel Liang.

Slides:



Advertisements
Similar presentations
L1-2:CSC ©Dr. Basheer M. Nasef Lecture #1 By Dr. Basheer M. Nasef.
Advertisements

Liang, Introduction to Java Programming, Sixth Edition, (c) 2005 Pearson Education, Inc. All rights reserved Chapter 1 Introduction to.
1 Chapter 3 Introduction to Computers, Programs, and Java.
Introduction to Java Kiyeol Ryu Java Programming Language.
Excerpts from Introduction to Java Programming, 4E Author: Y. Daniel Liang (Copyright by Prentice Hall)
Introduction to Java Programming, 4E
Liang, Introduction to Java Programming, Seventh Edition, (c) 2009 Pearson Education, Inc. All rights reserved Chapter 1 Introduction to.
 2003 Prentice Hall, Inc. All rights reserved. Customized by Sana Odeh for the use of this class. 1 Introduction to Computers and Programming in JAVA.
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved Chapter 1 Introduction to Computers,
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Chapter 1 Introduction to.
For more Lectures and Notes Visit
1 Chapter 1 Introduction to Computers, Programs, and Java.
Programming Software Applications Week 1 Dr. Xiaohong Gao Trent Park – B107, ext. 2252
Introduction to Computers, Programs, and Java. Objectives F To review computer basics, programs, and operating systems F To represent numbers in binary,
1. 2 Chapter 1 Introduction to Computers, Programs, and Java.
L EC. 01: J AVA FUNDAMENTALS Fall Java Programming.
Advanced OOP MCS-3 OOP BSCS-3 Lecture # 1
BASIC JAVA PROGRAMMING TUTORIAL. History  James Gosling and Sun Microsystems  Oak  Java, May 20, 1995, Sun World  Hot Java –The first Java-enabled.
CTIS251-Week 1 Engineering Software and Java Dr. Ozlem Albayrak.
CPCS 202 – Programming I Computer Science Department College of Computing and Information Technology King Abdul Aziz University.
Introduction to Java Programming with JBuilder 4
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.
Liang, Introduction to Java Programming, Fifth Edition, (c) 2005 Pearson Education, Inc. All rights reserved Chapter 1 Introduction to.
Chapter 1 Introduction to Computers, Programs, and Java
Chapter 1 Introduction to Computers, Programs, and Java 1.
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.
1 Chapter 1 Introduction to Computers, Programs, and Java.
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved Chapter 1 Introduction to Programs,
Introduction to Java Programming. History F James Gosling and Sun Microsystems F Oak F Java, May 20, 1995, Sun World F HotJava –The first Java-enabled.
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.
1 Part I : Chapter 01 Introduction to Java Programming.
1 Module Objective & Outline Module Objective: After completing this Module, you will be able to, appreciate java as a programming language, write java.
1 Chapter 3 Programs and Java. 2 Objectives F To review computer programs, and operating systems. F To represent numbers in binary, decimal, and hexadecimal.
ECOM 2314 Computer Programming I
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Chapter 1 Introduction to.
1 Chapter 1 Java –Originally for intelligent consumer-electronic devices –Then used for creating Web pages with dynamic content –Now also used for: Develop.
Jaeki Song ISQS6337 JAVA Lecture 03 Introduction to Java -The First Java Application-
Chapter 1: Introduction to Programs, and Java 1. Objectives To review programs (§ ). To understand the relationship between Java and the World Wide.
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved Chapter 1 Introduction to Programs.
Introduction to Java Programming with Forte Y. Daniel Liang.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved What is a Computer? A computer.
Object Oriented Rabie A. Ramadan, PhD Slides are exerted from different sources.
Introduction to Java Programming. Introduction Course Objectives Organization of the Book.
Java Programming Lecture 1 Instructors: Fu-Chiung Cheng ( 鄭福炯 ) Associate Professor Computer Science & Engineering Tatung University
Introduction To JAVA By Ihtesham Ul Haq. Course Objectives Upon completing the course, you will understand Upon completing the course, you will understand.
1 Chapter 3 Introduction to Computers, Programs, and Java.
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved Chapter 1 Introduction to Computers,
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.
Liang, Introduction to Java Programming, Ninth Edition, (c) 2013 Pearson Education, Inc. All rights reserved. 1 Chapter 1 Introduction to Computers, Programs,
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.
Introduction to Java Programming. 2 Chapter 1 Introduction to Java and Forte F What Is Java? F Getting Started With Java Programming –Create, Compile.
Java Programming: Advanced Topics1 Introduction to Advanced Java Programming Chapter 1.
Liang, Introduction to Java Programming, Ninth Edition, (c) 2013 Pearson Education, Inc. All rights reserved. 1 Chapter 1 Introduction to Computers, Programs,
1 Introduction to Java. 2 * 10% Assignments/ class participation * 10% Pop Quizzes * 05% Attendance * 25% Mid Term * 50% Final Term.
1 Chapter 1 Introduction to Computers, Programs, and 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
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved Chapter 1 Introduction to Computers,
SESSION 1 Introduction in Java. Objectives Introduce classes and objects Starting with Java Introduce JDK Writing a simple Java program Using comments.
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved Chapter 1 Introduction to Computers,
Chapter 1 Introduction to Computers, Programs, and Java
Chapter 1 Introduction to Computers, Programs, and Java
Chapter 1 Introduction to Computers, Programs, and Java
Anatomy of a Java Program
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:

Introduction to Java Programming, 4E Y. Daniel Liang

2 Course Objectives F Upon completing the course, you will understand –Create, compile, and run Java programs –Primitive data types –Java control flow –Methods –Arrays –Object-oriented programming

3 Course Objectives, cont. F You will be able to –Develop programs using Forte –Write simple programs using primitive data types, control statements, methods, and arrays. –Create and use methods –Develop a GUI interface and Java applets –Write interesting projects –Establish a firm foundation on Java concepts

4 Syllabus F Part I: Fundamentals of Programming –Introduction to Java –Primitive Data Types and Operations –Control Statements –Methods –Arrays

5 Syllabus, cont. F Part II: Object-Oriented Programming –Objects and Classes –Strings –Class Inheritance and Interfaces –Object-Oriented Software Development

6 Syllabus, cont. F Part III: GUI Programming –Chapter 10 Getting Started with GUI Programming –Chapter 11 Creating User Interfaces –Chapter 12 Applets and Advanced GUI

7 Syllabus, cont. F Part IV: Developing Comprehensive Projects –Chapter 13 Exception Handling –Chapter 14 Internationalization –Chapter 15 Multithreading –Chapter 16 Multimedia –Chapter 17 Input and Output –Chapter 18 Networking –Chapter 19 Java Data Structures

8 Introduction to Java F What Is Java? F Getting Started With Java Programming –Create, Compile and Running a Java Application

9 What Is Java? F History F Characteristics of Java

10 History F James Gosling and Sun Microsystems F Oak F Java, May 20, 1995, Sun World F HotJava –The first Java-enabled Web browser F JDK Evolutions F J2SE, J2ME, and J2EE

11 Characteristics of Java F Java is simple F Java is object-oriented F Java is distributed F Java is interpreted F Java is robust F Java is secure F Java is architecture-neutral F Java is portable F Java’s performance F Java is multithreaded F Java is dynamic

12 JDK Versions F JDK 1.02 (1995) F JDK 1.1 (1996) F Java 2 SDK v 1.2 (a.k.a JDK 1.2, 1998) F Java 2 SDK v 1.3 (a.k.a JDK 1.3, 2000) F Java 2 SDK v 1.4 (a.k.a JDK 1.4, 2002)

13 JDK Editions F Java Standard Edition (J2SE) – J2SE can be used to develop client-side standalone applications or applets. F Java Enterprise Edition (J2EE) – J2EE can be used to develop server-side applications such as Java servlets and Java ServerPages. F Java Micro Edition (J2ME). – J2ME can be used to develop applications for mobile devices such as cell phones.

14 Java IDE Tools F Forte by Sun MicroSystems F Borland JBuilder F Microsoft Visual J++ F NetBeans F Eclipse F IBM Visual Age for Java

15 Getting Started with Java Programming F A Simple Java Application F Compiling Programs F Executing Applications

16 A Simple Application Example 1.1 //This application program prints Welcome //to Java! package chapter1; public class Welcome { public static void main(String[] args) { System.out.println("Welcome to Java!"); }

17 Creating and Compiling Programs F On command line –javac file.java

18 Executing Applications F On command line –java classname

19 Example javac Welcome.java java Welcome output:...

20 Compiling and Running a Program Where are the files stored in the directory?

21 Anatomy of a Java Program F Comments F Package F Reserved words F Modifiers F Statements F Blocks F Classes F Methods F The main method

22 Comments In Java, comments are preceded by two slashes (//) in a line, or enclosed between /* and */ in one or multiple lines. When the compiler sees //, it ignores all text after // in the same line. When it sees /*, it scans for the next */ and ignores any text between /* and */.

23 Package The second line in the program (package chapter1;) specifies a package name, chapter1, for the class Welcome. Forte compiles the source code in Welcome.java, generates Welcome.class, and stores Welcome.class in the chapter1 folder.

24 Reserved Words Reserved words or keywords are words that have a specific meaning to the compiler and cannot be used for other purposes in the program. For example, when the compiler sees the word class, it understands that the word after class is the name for the class. Other reserved words in Example 1.1 are public, static, and void.

25 Modifiers Java uses certain reserved words called modifiers that specify the properties of the data, methods, and classes and how they can be used. Examples of modifiers are public and static. Other modifiers are private, final, abstract, and protected. A public datum, method, or class can be accessed by other programs. A private datum or method cannot be accessed by other programs. Modifiers are discussed in Chapter 6, "Objects and Classes."

26 Statements A statement represents an action or a sequence of actions. The statement System.out.println("Welcome to Java!") in the program in Example 1.1 is a statement to display the greeting "Welcome to Java!" Every statement in Java ends with a semicolon (;).

27 Blocks A pair of braces in a program forms a block that groups components of a program.

28 Classes The class is the essential Java construct. A class is a template or blueprint for objects. To program in Java, you must understand classes and be able to write and use them. For now, though, understand that a program is defined by using one or more classes.

29 Methods What is System.out.println? It is a method: a collection of statements that performs a sequence of operations to display a message on the console. It can be used even without fully understanding the details of how it works. It is used by invoking a statement with a string argument. The string argument is enclosed within parentheses. In this case, the argument is "Welcome to Java!" You can call the same println method with a different argument to print a different message.

30 main Method The main method provides the control of program flow. The Java interpreter executes the application by invoking the main method. The main method looks like this: public static void main(String[] args) { // Statements; }

31 Displaying Text in a Message Dialog Box you can use the showMessageDialog method in the JOptionPane class. JOptionPane is one of the many predefined classes in the Java system, which can be reused rather than “reinventing the wheel.” RunSource

32 The showMessageDialog Method JOptionPane.showMessageDialog(null, "Welcome to Java!", "Example 1.2", JOptionPane.INFORMATION_MESSAGE));

33 The exit Method Use Exit to terminate the program and stop all threads. NOTE: When your program starts, a thread is spawned to run the program. When the showMessageDialog is invoked, a separate thread is spawned to run this method. The thread is not terminated even you close the dialog box. To terminate the thread, you have to invoke the exit method.