Introduction to Java. Liang, Introduction to Java Programming, Ninth Edition, (c) 2013 Pearson Education, Inc. All rights reserved.

Similar documents
Java Language. Programs. Computer programs, known as software, are instructions to the computer. You tell a computer what to do through programs.

Module 1: Introduction to Computers, Programs, and Java

Chapter 1 Introduction to Computers, Programs, and Java

Chapter 1 Introduction to Computers, Programs, and Java

Chapter 1: Introduction to Computers, Programs, and Java

Getting Started. Chapter 1. Java Programming FROM THE BEGINNING. Chapter 1: Getting Started

Chapter 1 Introduction to Computers, Programs, and Java

Chapter 1 Introduction to Computers, Programs, and Java

Lecture 1: Introduction to Java

Chapter 1 Introduction to Computers, Programs, and Java

Chapter 1 Introduction to Computers, Programs, and Java. What is a Computer? A Bit of History

Introduction. Introduction to OOP with Java. Lecture 01: Introduction to OOP with Java - AKF Sep AbuKhleiF -

II. Compiling and launching from Command-Line, IDE A simple JAVA program

Chapter 1 Introduction to Java

Introduction to OOP with Java. Instructor: AbuKhleif, Mohammad Noor Sep 2017

Introduction to Computers, Programs, and Java. CSE 114, Computer Science 1 Stony Brook University

Chapter 1 Introduction to Computers, Programs, and Java

Networks Programming Engr. Abdul-Rahman Mahmood MS, PMP, MCP, QMR(ISO9001:2000)

Objectives. Chapter 1 Introduction to Computers, Programs, and Java. What is a Computer?

Lesson 01 Introduction

Chapter 1 Introduction to Computers, Programs, and Java

Introduction to Java Programming CPIT 202. WEWwwbvxnvbxmnhsgfkdjfcn

Introduction to OOP Using Java Pearson Education, Inc. All rights reserved.

CMSC 150 LECTURE 1 INTRODUCTION TO COURSE COMPUTER SCIENCE HELLO WORLD

Getting Started with Java. Atul Prakash

12/22/11. Java How to Program, 9/e. Help you get started with Eclipse and NetBeans integrated development environments.

IQTIDAR ALI Lecturer IBMS Agriculture University Peshawar

Eng. Mohammed Alokshiya

Lecture 1: Introduction to Java

Chapter 1 Introduction to Computers, Programs, and Java

Learning objectives. The Java Environment. Java timeline (cont d) Java timeline. Understand the basic features of Java

Chapter 2 Author Notes

Assoc. Prof. Dr. Marenglen Biba. (C) 2010 Pearson Education, Inc. All rights reserved.

History Introduction to Java Characteristics of Java Data types

Introduction to Visual Basic and Visual C++ Introduction to Java. JDK Editions. Overview. Lesson 13. Overview

Introduction to Java. Lecture 1 COP 3252 Summer May 16, 2017

Assoc. Prof. Dr. Marenglen Biba. (C) 2010 Pearson Education, Inc. All rights reserved.

Eng. Mohammed S. Abdualal

The Computer System. Hardware = Physical Computer. Software = Computer Programs. People = End Users & Programmers. people

Zhifu Pei CSCI5448 Spring 2011 Prof. Kenneth M. Anderson

Chapter 1. Introduction

Java Programming Language Mr.Rungrote Phonkam

Programming: detailed instructions which tell the computer hardware what to do aka software Computer Science: the study NOT of computers, but of what

Supplement D: Expanded Guidelines on Programming Style and Documentation

MEAP Edition Manning Early Access Program Get Programming with Java Version 1

Java Bytecode (binary file)

Lecture (01) Getting started. Dr. Ahmed ElShafee

CHAPTER 1 INTRODUCTION TO COMPUTERS, PROGRAMS, AND JAVA. Objectives

Expanded Guidelines on Programming Style and Documentation

Object Oriented Concepts and Programming (CSC244) By Dr. Tabbasum Naz

Chapter 1. Introduction to Computers and Java Objects. Background information. » important regardless of programming language. Introduction to Java

Tutorial 1 CSC 201. Java Programming Concepts عؾادئماظربجمةمبادؿكدامماجلاصا

Pace University. Fundamental Concepts of CS121 1

Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Outline. Introduction to Java. What Is Java? History. Java 2 Platform. Java 2 Platform Standard Edition. Introduction Java 2 Platform

Introduction Welcome! Before you start Course Assessments The course at a glance How to pass M257

CS 177 Recitation. Week 1 Intro to Java

CS 152: Data Structures with Java Hello World with the IntelliJ IDE

C Language, Token, Keywords, Constant, variable

Objectives. Problem Solving. Introduction. An overview of object-oriented concepts. Programming and programming languages An introduction to Java

Full file at

Course Outline. Introduction to java

Project 1. Java Control Structures 1/17/2014. Project 1 and Java Intro. Project 1 (2) To familiarize with

Introduction to Programming

Part I: Fundamentals of Programming

Computer Science. ESC 120 Introduction to Engineering Design

Introduction to Java Applications; Input/Output and Operators

Section 2.2 Your First Program in Java: Printing a Line of Text

Features of C. Portable Procedural / Modular Structured Language Statically typed Middle level language

Chapter 2: Programming Concepts

Low-Level Languages. Computer Programs and Programming Languages

Introduction To Java. Chapter 1. Origins of the Java Language. Origins of the Java Language. Objects and Methods. Origins of the Java Language

History of Java. Java was originally developed by Sun Microsystems star:ng in This language was ini:ally called Oak Renamed Java in 1995

Introduction to JAVA Programming Language

Assignment Marking Criteria

CHAPTER 1. Introduction to JAVA Programming

Introduction to Java Programming

Basic Programming Language Syntax

Eclipse Tutorial. For Introduction to Java Programming By Y. Daniel Liang

Introduction. A. Bellaachia Page: 1

B.V. Patel Institute of BMC & IT, UTU 2014

CSE 421 Course Overview and Introduction to Java

Java Programming Fundamentals - Day Instructor: Jason Yoon Website:

Lab # 2. For today s lab:

Welcome to Python 3. Some history

IT 374 C# and Applications/ IT695 C# Data Structures

Discovering Computers 2008

Introduction to Programming with Java

CIS260 Summer Exam 1 First Name Last Name: 2) is the brain of a computer. 2) A) Memory B) Hardware C) Disk D) CPU

Chapter 1: Introduction to Computers and Java

8/23/2014. Chapter Topics. Introduction. Java History. Why Program? Java Applications and Applets. Chapter 1: Introduction to Computers and Java

Assoc. Prof. Dr. Marenglen Biba. (C) 2010 Pearson Education, Inc. All rights reserved.

Identifiers. Identifiers are the words a programmer uses in a program Some identifiers are already defined. Some are made up by the programmer:

UEE1302 (1102) F10: Introduction to Computers and Programming

An Introduction to Software Engineering. David Greenstein Monta Vista High School

Computer Components. Software{ User Programs. Operating System. Hardware

Discovering Computers Chapter 13 Programming Languages and Program Development

A PROGRAM IS A SEQUENCE of instructions that a computer can execute to

1/14/2014. Introduction to CSE 1325 Object Oriented Programming (Using Java) Introduction (Cont.) Introduction

C++ Spring Break Packet 11 The Java Programming Language

Transcription:

Introduction to Java 1

Programs Computer programs, known as software, are instructions to the computer. You tell a computer what to do through programs. Programs are written using programming languages. 2

Programming Languages Machine Language Assembly Language High-Level Language 1101101010011010 Computers can run instructions only in machine language! 3

Programming Languages Machine Language Assembly Language High-Level Language Humans are not comfortable with machine languages, so they made low-level languages like Assembly. ADDF3 R1, R2, R3 Assembly Source File Machine Code File ADDF3 R1, R2, R3 Assembler 1101101010011010 4

Programming Languages Machine Language Assembly Language High-Level Language Then high-level languages were invented which are English-like and easy to learn and program. Sum = 4 + 5; Area = 5 * 5 * 3.1415; 5

Popular High-Level Languages Language Ada BASIC C C++ C# COBOL FORTRAN Java Pascal Python Visual Basic Description Named for Ada Lovelace, who worked on mechanical general-purpose computers. The Ada language was developed for the Department of Defense and is used mainly in defense projects. Beginner s All-purpose Symbolic Instruction Code. It was designed to be learned and used easily by beginners. Developed at Bell Laboratories. C combines the power of an assembly language with the ease of use and portability of a high-level language. C++ is an object-oriented language, based on C. Pronounced C Sharp. It is a hybrid of Java and C++ and was developed by Microsoft. COmmon Business Oriented Language. Used for business applications. FORmula TRANslation. Popular for scientific and mathematical applications. Developed by Sun Microsystems, now part of Oracle. It is widely used for developing platformindependent Internet applications. Named for Blaise Pascal, who pioneered calculating machines in the seventeenth century. It is a simple, structured, general-purpose language primarily for teaching programming. A simple general-purpose scripting language good for writing short programs. Visual Basic was developed by Microsoft and it enables the programmers to rapidly develop graphical user interfaces. 6

Interpreting/Compiling Source Code A program written in a high-level language is called a source program or source code. Source Code Machine Code (Or Virtual Machine Code) Execute The translation can be done using another programming tool called an interpreter or a compiler. 7

Interpreting Source Code An interpreter reads one statement from the source code, translates it to the machine code or virtual machine code, and then executes it right away. High-level Source File area = 5 * 5 * 3.1415;... Interpreter Output 8

Compiling Source Code A compiler translates the entire source code into a machine-code file, and the machine-code file is then executed, as shown in the following figure. High-level Source File Machine-code File area = 5 * 5 * 3.1415;... Compiler 0101100011011100 1111100011000100 Executor Output 9

A Simple Java Program //This program prints Welcome to Java! public class Welcome { public static void main(string[] args) { System.out.println("Welcome to Java!"); 10

Creating and Editing Using gedit To use, type gedit Welcome.java from the terminal. 11

Compiling Java program javac Welcome.java javac is the java compiler It translates Java source code to java bytecode (a type of virtual machine code) 12

Running Java program java Welcome Java Virtual Machine is a software that can execute Java bytecode. 13

Machine Independency Java Bytecode Java Virtual Machine Any Computer 14

Trace a Program Execution Enter main method //This program prints Welcome to Java! public class Welcome { public static void main(string[] args) { System.out.println("Welcome to Java!"); 15

Trace a Program Execution Execute statement //This program prints Welcome to Java! public class Welcome { public static void main(string[] args) { System.out.println("Welcome to Java!"); 16

Trace a Program Execution //This program prints Welcome to Java! public class Welcome { public static void main(string[] args) { System.out.println("Welcome to Java!"); print a message to the console 17

Hierarchy of a Java Program A book (program) consists of a number of chapters (classes) Each chapter (class) consists of a number of paragraphs (methods) Each paragraph (method) consists of a number of sentences (statements) Each sentence (statement) must obey the syntax rules in the English (Java) language 18

Class Every Java program must have at least one class. Each class has a name. By convention, class names start with an uppercase letter. In this example, the class name is Welcome. //This program prints Welcome to Java! public class Welcome { public static void main(string[] args) { System.out.println("Welcome to Java!"); 19

Method A method contains a set of statements! In order to run a class, the class must contain a method named main. The program is executed from the main method. //This program prints Welcome to Java! public class Welcome { public static void main(string[] args) { System.out.println("Welcome to Java!"); 20

Statement A statement represents an action or a sequence of actions. //This program prints Welcome to Java! public class Welcome { public static void main(string[] args) { System.out.println("Welcome to Java!"); 21

Statement Terminator Every statement in Java ends with a semicolon (;). //This program prints Welcome to Java! public class Welcome { public static void main(string[] args) { System.out.println("Welcome to Java!"); 22

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. //This program prints Welcome to Java! public class Welcome { public static void main(string[] args) { System.out.println("Welcome to Java!"); 23

Blocks A pair of braces in a program forms a block that groups components of a program. public class Test { public static void main(string[] args) { System.out.println("Welcome to Java!"); Method block Class block 24

Special Symbols Character Name Description { () [] // " " ; Opening and closing braces Opening and closing parentheses Opening and closing brackets Double slashes Opening and closing quotation marks Semicolon Denotes a block to enclose statements. Used with methods. Denotes an array. Precedes a comment line. Enclosing a string (i.e., sequence of characters). Marks the end of a statement. 25

{ // This program prints Welcome to Java! public class Welcome { public static void main(string[] args) { System.out.println("Welcome to Java!"); 26

( ) // This program prints Welcome to Java! public class Welcome { public static void main(string[] args) { System.out.println("Welcome to Java!"); 27

; // This program prints Welcome to Java! public class Welcome { public static void main(string[] args) { System.out.println("Welcome to Java!"); 28

// // This program prints Welcome to Java! public class Welcome { public static void main(string[] args) { System.out.println("Welcome to Java!"); 29

" " // This program prints Welcome to Java! public class Welcome { public static void main(string[] args) { System.out.println("Welcome to Java!"); 30

Programming Style and Documentation Appropriate Comments Naming Conventions Proper Indentation and Spacing Lines Block Styles 31

Appropriate Comments Include a summary at the beginning of the program to explain what the program does, its key features, its supporting data structures, and any unique techniques it uses. 32

Naming Conventions Choose meaningful and descriptive names. Class names: Capitalize the first letter of each word in the name. For example, the class name ComputeExpression. 33

Proper Indentation and Spacing Indentation Indent two spaces. Spacing Use blank line to separate segments of the code. 34

Block Styles Use end-of-line style for braces. Next-line style public class Test { public static void main(string[] args) { System.out.println("Block Styles"); public class Test { public static void main(string[] args) { System.out.println("Block Styles"); End-of-line style 35

JDK (Java Development Kit) - The Java Development Kit (JDK) is a software development environment used for developing Java applications. - It includes the Java Runtime Environment (JRE), an executer/launcher (java), a compiler (javac), an archiver (jar), a documentation generator (javadoc) and other tools needed in Java development. - Newest Version: JDK 1.7 (2011) a. k. a. JDK 7 or Java 7 36

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