Chapter 1 Java Programming Review. Introduction Java is platform-independent, meaning that you can write a program once and run it anywhere. Java programs.

Slides:



Advertisements
Similar presentations
Introduction to C Programming
Advertisements

C Language.
Programming Languages and Paradigms The C Programming Language.
Chapter 41 Variables and JSP Control Structures JavaServer Pages By Xue Bai.
Chapter 7: User-Defined Functions II
Chapter 7 User-Defined Methods. Chapter Objectives  Understand how methods are used in Java programming  Learn about standard (predefined) methods and.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2005 Pearson Education, Inc. All rights reserved Chapter 2 1 Chapter 2 Primitive.
1 Chapter 4 Language Fundamentals. 2 Identifiers Program parts such as packages, classes, and class members have names, which are formally known as identifiers.
1 Chapter 7 User-Defined Methods Java Programming from Thomson Course Tech, adopted by kcluk.
Java Syntax Primitive data types Operators Control statements.
Loops – While, Do, For Repetition Statements Introduction to Arrays
CS 106 Introduction to Computer Science I 10 / 04 / 2006 Instructor: Michael Eckmann.
ECE122 L11: For loops and Arrays March 8, 2007 ECE 122 Engineering Problem Solving with Java Lecture 11 For Loops and Arrays.
Java Programming: From Problem Analysis to Program Design, 4e Chapter 7 User-Defined Methods.
Chapter 2 - Java Programming Fundamentals1 Chapter 2 Java Programming Fundamentals.
Chapter 7: User-Defined Methods
VB .NET Programming Fundamentals
Day 4 Objectives Constructors Wrapper Classes Operators Java Control Statements Practice the language.
Introduction to Java Appendix A. Appendix A: Introduction to Java2 Chapter Objectives To understand the essentials of object-oriented programming in Java.
 Value, Variable and Data Type  Type Conversion  Arithmetic Expression Evaluation  Scope of variable.
DAT602 Database Application Development Lecture 5 JAVA Review.
By Nicholas Policelli An Introduction to Java. Basic Program Structure public class ClassName { public static void main(String[] args) { program statements.
ASP.NET Programming with C# and SQL Server First Edition Chapter 3 Using Functions, Methods, and Control Structures.
Introduction to Arrays in Java Corresponds with Chapter 6 of textbook.
Hello.java Program Output 1 public class Hello { 2 public static void main( String [] args ) 3 { 4 System.out.println( “Hello!" ); 5 } // end method main.
Introduction to PHP A user navigates in her browser to a page that ends with a.php extension The request is sent to a web server, which directs the request.
University of Palestine software engineering department Introduction to data structures Control Statements: Part 1 instructor: Tasneem Darwish.
Java Programming: From Problem Analysis to Program Design, 4e Chapter 2 Basic Elements of Java.
CPS120: Introduction to Computer Science Decision Making in Programs.
Chapter 2 Functions and Control Structures PHP Programming with MySQL 2 nd Edition.
CHAPTER 4 GC 101 Data types. DATA TYPES  For all data, assign a name (identifier) and a data type  Data type tells compiler:  How much memory to allocate.
1 Programming Java Java Basics. 2 Java Program Java Application Program Application Program written in general programming language Applet Program running.
XP Tutorial 10New Perspectives on HTML and XHTML, Comprehensive 1 Working with JavaScript Creating a Programmable Web Page for North Pole Novelties Tutorial.
Chapter 3 - Structured Program Development Outline 3.1Introduction 3.2Algorithms 3.3Pseudocode 3.4Control Structures 3.5The If Selection Structure 3.6The.
Chapter 3 Functions, Events, and Control Structures JavaScript, Third Edition.
Introduction to Java Java Translation Program Structure
BEGINNING PROGRAMMING.  Literally – giving instructions to a computer so that it does what you want  Practically – using a programming language (such.
JavaScript, Fourth Edition
Chapter 15 JavaScript: Part III The Web Warrior Guide to Web Design Technologies.
Java Nuts and Bolts Variables and Data Types Operators Expressions Control Flow Statements Arrays and Strings.
 In the java programming language, a keyword is one of 50 reserved words which have a predefined meaning in the language; because of this,
CSI 3125, Preliminaries, page 1 Data Type, Variables.
By Mr. Muhammad Pervez Akhtar
Chapter 6 Methods Chapter 6 - Methods.
Spring 2009 Programming Fundamentals I Java Programming XuanTung Hoang Lecture No. 8.
UMass Lowell Computer Science Java and Distributed Computing Prof. Karen Daniels Fall, 2000 Lecture 8 Java Fundamentals Control Structures Fri.
2: Basics Basics Programming C# © 2003 DevelopMentor, Inc. 12/1/2003.
An Introduction to Java – Part 1 Erin Hamalainen CS 265 Sec 001 October 20, 2010.
Repetition Statements (Loops). 2 Introduction to Loops We all know that much of the work a computer does is repeated many times. When a program repeats.
1 1 Chapter 2 Elementary Programming. 2 2 Motivations In the preceding chapter, you learned how to create, compile, and run a Java program. Starting from.
JAVA Programming (Session 2) “When you are willing to make sacrifices for a great cause, you will never be alone.” Instructor: รัฐภูมิ เถื่อนถนอม
1 Lecture # 2. * Introducing Programming with an Example * Identifiers, Variables, and Constants * Primitive Data Types * Byte, short, int, long, float,
Lecture 3: More Java Basics Michael Hsu CSULA. Recall From Lecture Two  Write a basic program in Java  The process of writing, compiling, and running.
 It is a pure oops language and a high level language.  It was developed at sun microsystems by James Gosling.
PHP using MySQL Database for Web Development (part II)
Information and Computer Sciences University of Hawaii, Manoa
Chapter 7 User-Defined Methods.
Elementary Programming
Java Primer 1: Types, Classes and Operators
BY GAWARE S.R. COMPUTER SCI. DEPARTMENT
Chapter 3 Introduction to Classes, Objects Methods and Strings
Java - Data Types, Variables, and Arrays
An Introduction to Java – Part I, language basics
PHP.
Chap 1 Chap 2 Chap 3 Chap 5 Surprise Me
CPS120: Introduction to Computer Science
Single-Dimensional Arrays chapter6
Chapter 2 Primitive Data Types and Operations
C Language B. DHIVYA 17PCA140 II MCA.
Corresponds with Chapter 5
Presentation transcript:

Chapter 1 Java Programming Review

Introduction Java is platform-independent, meaning that you can write a program once and run it anywhere. Java programs can be embedded in HTML pages and downloaded by Web browsers to bring live animation and interaction to Web clients. Java source files end with the.java extension. Every class is compiled into a separate file bytecode that has the same name as the class and ends with the.class extension.

Introduction To compile a Java source code file, use the javac command. To run a Java class, use the java command. Every Java program is a set of class definitions. The keyword class introduces a class definition. The contents of the class are included in a block. A block begins with an opening brace “{“ and ends with the closing “}”. Methods are contained in a class. A Java application must have a main method. The main method is the entry point where the application program starts when it is executed.

Problem Solving Programming is a process of problem solving Problem-solving technique includes analyse the problem, outline the problem requirements, and design the steps (called algorithm). Three steps problem-solving process in the programming environment: –Analyse, outline the problem and its solution requirements. Design the algorithm to solve the problem. –Implement the algorithm uses any programming language and verify it. –Maintain or modify the program.

Primitive Data Types and Operations Four integer types (byte, short, int, long) that represent integers of four different sizes. Two floating-point types (float, double) that represent floating-point numbers of two different precisions. Character type (char) represents a single character All these called primitive data types. When they are declared, the variables of these types are created and assigned memory space.

Primitive Data Types and Operations Numeric operations: + (addition), - (substraction), * (multiplication), / (division), % (remainder). Increment operator (++), decrement operator (-- ). Casting – convert a value of one type into another type. Two types: widening and narrowing type. Three types of programming errors: syntax errors, runtime errors and logic errors.

Selection Statements Boolean types – represents a true or false value. Boolean operators - &&, &, ||, |, !, and ^. Relational operators -, >=. Selection statements are used for building selection steps into programs. Types: if, if…else, nested if, switch and conditional expressions. if statement – control decisions based on Boolean expression. switch statement – control decisions based on a switch expression. Keyword break is optional. Conditional expression – booleanExpression ? Expression1 : expression2;

Loop Statements while – checks the loop-continuation-condition first and then execute the loop body. do-while – execute the loop body first and then check the loop-continuation-condition. for – execute a loop body a predictable number of times. Has three parts: initialise a control variable, loop-continuation-condition, adjust the control variable. Keyword break – immediately ends the innermost loop and continue – only ends the current iterations.

Methods Method header specifies the modifiers, return value type, method name and parameters of the method. Example: public static int max (int num1, int num2) { …} A method may return a value or not (void). The arguments that are passed to a method should have the same number, type, and order as the parameters in the method definition.

Methods When a program calls a method, program control is transferred to the called method. A called method returns control to the caller when its return statement is executed or when its method-ending closing brace is reached. A method can be overloaded – two methods can have the same name as long as their method parameter lists differ. The scope of a local variable is limited locally to a method.

Arrays Syntax: dataType[ ] arrayRefVar or dataType arrayRefVar[ ] The declaration of an array variable does not allocate any space in memory for the array. An array variable contains a reference to an array. Elements can only be assigned to an array if it has already been created using new operator: new dataType[arraysize] myList

Arrays Each element in the array is represented using the syntax arrayRefVar[index]. An index must be an integer. After an array is created, its size becomes permanent and can be obtained using arrayRefVar.length Array initialiser – combines declaring an array, creating an array, and initialising in one statement: dataType[ ] arrayRefVar = {value0, value1, …, valuek);

Arrays Passing an array argument to a method is actually passing the reference of the array. Two-dimensional array: dataType[ ][ ] arrayRefVar or dataType arrayRefVar[ ][ ]