University of Palestine software engineering department Introduction to data structures Introduction to java application instructor: Tasneem Darwish.

Slides:



Advertisements
Similar presentations
Introduction to Java.
Advertisements

CS0007: Introduction to Computer Programming Console Output, Variables, Literals, and Introduction to Type.
The Web Warrior Guide to Web Design Technologies
IT151: Introduction to Programming
Dale Roberts Introduction to Java - First Program Dale Roberts, Lecturer Computer Science, IUPUI Department of Computer and.
Chapter 1 Introduction to JAVA. Why Learn JAVA? Java is one of the fastest growing programming language in the world. Java is one of the fastest growing.
 2005 Pearson Education, Inc. All rights reserved Introduction.
1 Chapter 2 Introduction to Java Applications Introduction Java application programming Display ____________________ Obtain information from the.
Introduction to C++ Programming. A Simple Program: Print a Line of Text // My First C++ Program #include int main( ) { cout
 C++ programming facilitates a disciplined approach to program design. ◦ If you learn the correct way, you will be spared a lot of work and frustration.
Introduction to C Programming
INSTRUCTOR: SHIH-SHINH HUANG Windows Programming Using Java Chapter2: Introduction to Java Applications 1.
Chapter 2 - Introduction to Java Applications
Introduction To Computers and Programming Lecture 2: Your first program Professor: Evan Korth New York University.
1 Outline 13.1Introduction 13.2A Simple Program: Printing a Line of Text in a Web Page 13.3Another JavaScript Program: Adding Integers 13.4Memory Concepts.
 2008 Pearson Education, Inc. All rights reserved JavaScript: Introduction to Scripting.
CMT Programming Software Applications
 2007 Pearson Education, Inc. All rights reserved Introduction to C Programming.
 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.
Introduction to C Programming
Introduction to scripting
Java™ How to Program, 9/e © Copyright by Pearson Education, Inc. All Rights Reserved.
Using C Programming Language.  The programs that run on a computer are referred to as software.  You’ll learn key programming methodology that are enhancing.
Using C Programming Language.  The programs that run on a computer are referred to as software.  You’ll learn key programming methodology that are enhancing.
Java Applications & Program Design
Chapter 2 How to Compile and Execute a Simple Program.
 2005 Pearson Education, Inc. All rights reserved Introduction to Java Applications.
 2005 Pearson Education, Inc. All rights reserved Introduction to Java Applications.
1 2 2 Introduction to Java Applications Introduction Java application programming –Display messages –Obtain information from the user –Arithmetic.
Java™ How to Program, 9/e © Copyright by Pearson Education, Inc. All Rights Reserved.
Android How to Program, 2/e © Copyright by Pearson Education, Inc. All Rights Reserved.
 2001 Prentice Hall, Inc. All rights reserved. 1 Chapter 7 - JavaScript: Introduction to Scripting Outline 7.1 Introduction 7.2 Simple Program: Printing.
Chapter 2 Overview of C Part I J. H. Wang ( 王正豪 ), Ph. D. Assistant Professor Dept. Computer Science and Information Engineering National Taipei University.
Jaeki Song ISQS6337 JAVA Lecture 03 Introduction to Java -The First Java Application-
Intro and Review Welcome to Java. Introduction Java application programming Use tools from the JDK to compile and run programs. Videos at
Java Programming, Second Edition Chapter One Creating Your First Java Program.
CHAPTER 3 GC Java Fundamentals. 2 BASICS OF JAVA ENVIRONMENT  The environment  The language  Java applications programming Interface API  Various.
Week 1 Algorithmization and Programming Languages.
 2000 Prentice Hall, Inc. All rights reserved. 1 Chapter 2 - Introduction to Java Applications Outline 2.1Introduction 2.2A Simple Program: Printing a.
 Pearson Education, Inc. All rights reserved Introduction to Java Applications.
 Pearson Education, Inc. All rights reserved Introduction to Java Applications.
Internet & World Wide Web How to Program, 5/e © by Pearson Education, Inc. All Rights Reserved.
 2000 Deitel & Associates, Inc. All rights reserved. Outline 8.1Introduction 8.2A Simple Program: Printing a Line of Text in a Web Page 8.3Another JavaScript.
Internet & World Wide Web How to Program, 5/e © by Pearson Education, Inc. All Rights Reserved.
 2008 Pearson Education, Inc. All rights reserved JavaScript: Introduction to Scripting.
Using Java MINISTRY OF EDUCATION & HIGHER EDUCATION COLLEGE OF SCIENCE AND TECHNOLOGY KHANYOUNIS- PALESTINE.
Internet & World Wide Web How to Program, 5/e © by Pearson Education, Inc. All Rights Reserved.
Java™ How to Program, 10/e Late Objects Version © Copyright by Pearson Education, Inc. All Rights Reserved.
Chapter 3 Introducing Java. Objectives and Goals 1. Define terminology associated with object- oriented programming. 2. Explain why Java is a widely used.
REEM ALMOTIRI Information Technology Department Majmaah University.
Introduction to Java Applications
Chapter 6 JavaScript: Introduction to Scripting
CSC201: Computer Programming
Yanal Alahmad Java Workshop Yanal Alahmad
Chapter 2, Part I Introduction to C Programming
Chapter 2 Introduction to Java Applications
Chapter 2 Introduction to Java Applications
Data types and variables
Introduction to Scripting
Java programming lecture one
Fundamentals of Java Programs, Input/Output, Variables, and Arithmetic
CET 3640 – Lecture 2 Java Syntax Chapters 2, 4, 5
WEB PROGRAMMING JavaScript.
MSIS 655 Advanced Business Applications Programming
Introduction to Java Applications
Java How to Program, 11/e Questions?
Computer Programming-1 CSC 111
CS313T Advanced Programming language
Presentation transcript:

University of Palestine software engineering department Introduction to data structures Introduction to java application instructor: Tasneem Darwish

Outlines History of Java Java Class Libraries A First Program in Java: Printing a Line of Text Modifying Our First Java Program Displaying Text with printf

History of Java Sun Microsystems in 1991 funded an internal corporateresearch project code-named Green, which resulted in a C++-based language that its creator, James Gosling, called Oak after an oak tree outside his window at Sun It was later discovered that there already was a computer language by that name. When a group of Sun people visited a local coffee shop, the name Java was suggested, and it stuck.

History of Java The Green project ran into some difficulties. The marketplace for intelligent consumer- electronic devices was not developing in the early 1990s as quickly as Sun had anticipated. The project was in danger of being cancelled. but the World Wide Web exploded in popularity in 1993, and Sun people saw the immediate potential of using Java to add dynamic content, such as interactivity and animations, to web pages.

Java Class Libraries Java programs consist of pieces called classes. Classes include pieces called methods that perform tasks and return information when they complete them

Java Class Libraries Programmers can create each piece they need to form Java programs. However, most Java programmers take advantage of the rich collections of existing classes in the Java class libraries, which are also known as the Java APIs (Application Programming Interfaces).

A First Program in Java: Printing a Line of Text Every time you use a computer, you execute various applications that perform tasks for you. For example, your application helps you send and receive e- mail. Computer programmers create such applications by writing computer programs.

A First Program in Java: Printing a Line of Text A Java application is a computer program that executes when you use the java command to launch the Java Virtual Machine (JVM).

A First Program in Java: Printing a Line of Text

Line 1 begins with //, indicating that the remainder of the line is a comment This helps other people read and understand your programs. The Java compiler ignores comments, so they do not cause the computer to perform any action when the program is run.

A First Program in Java: Printing a Line of Text A comment that begins with // is called an end-of-line (or single-line) comment, because the comment terminates at the end of the line on which it appears. A // comment also can begin in the middle of a line and continue until the end of that line (as in lines 11 and 13).

A First Program in Java: Printing a Line of Text Traditional comments (also called multiple-line comments), such as This type of comment can be spread over several lines. It begins with the delimiter /* and ends with */. All text between the delimiters is ignored by the compiler.

A First Program in Java: Printing a Line of Text Java also provides Javadoc comments that are delimited by /** and */. As with traditional comments, all text between the Javadoc comment delimiters is ignored by the compiler. Javadoc comments enable programmers to embed program documentation directly in their programs. The javadoc utility program (part of the Java SE Development Kit) reads Javadoc comments and uses them to prepare your program’s documentation in HTML format

A First Program in Java: Printing a Line of Text Line 3 is a blank line. Programmers use blank lines and space characters to make programs easier to read. Together, blank lines, space characters and tab characters are known as white space. (Space characters and tabs are known specifically as white-space characters.) White space is ignored by the compiler. using white space enhance program readability.

A First Program in Java: Printing a Line of Text

Line 4 begins a class declaration for class Welcome1. Every program in Java consists of at least one class declaration that is defined by you—the programmer. These are known as programmer defined classes or user-defined classes. The class keyword introduces a class declaration in Java and is immediately followed by the class name (Welcome1). Keywords (sometimes called reserved words) are reserved for use by Java and are always spelled with all lowercase letters. The complete list of Java keywords is shown in Appendix C.

A First Program in Java: Printing a Line of Text By convention, all class names in Java begin with a capital letter and capitalize the first letter of each word they include (e.g., SampleClassName). A Java class name is an identifier an identifier a series of characters consisting of letters, digits, underscores ( _ ) and dollar signs ($), it does not begin with a digit and does not contain spaces.

Class work Write five valid identifier and five invalid identifiers

Class work Some valid identifiers are: Welcome1, $value, _value, m_inputField1 button7. Some invalid identifiers are: 1 welcome, 3button, input field, m 3 n, $ value

A First Program in Java: Printing a Line of Text Java is case sensitive—that is, uppercase and lowercase letters are distinct, so a1 and A1 are different (but both valid) identifiers. A left brace (at line 5 in this program), {, begins the body of every class declaration. A corresponding right brace (at line 13), }, must end each class declaration.

A First Program in Java: Printing a Line of Text Line 7 (the main method) is the starting point of every Java application. The parentheses after the identifier main indicate that it is a program building block called a method. Java class declarations normally contain one or more methods. For a Java application, exactly one of the methods must be called main, otherwise, the JVM will not execute the application

A First Program in Java: Printing a Line of Text Methods are able to perform tasks and return information when they complete their tasks. Keyword void indicates that this method will perform a task but will not return any information when it completes its task The left brace, {, in line 8 begins the body of the method declaration. A corresponding right brace, }, must end the method declaration’s body (line 11 of the program).

A First Program in Java: Printing a Line of Text Line 9 System.out.println( "Welcome to Java Programming!" ); instructs the computer to perform an action— namely, to print the string of characters contained between the double quotation marks (but not the quotation marks themselves).

A First Program in Java: Printing a Line of Text A string is sometimes called a character string, a message or a string literal. We refer to characters between double quotation marks simply as strings. White-space characters in strings are not ignored by the compiler.

A First Program in Java: Printing a Line of Text System.out is known as the standard output object. System.out allows Java applications to display sets of characters in the command window from which the Java application executes Method System.out.println displays (or prints) a line of text in the command window. The string in the parentheses in line 9 is the argument to the method.

A First Program in Java: Printing a Line of Text Method System.out.println performs its task by displaying (also called outputting) its argument in the command window. When System.out.println completes its task, it positions the output cursor (the location where the next character will be displayed) to the beginning of the next line in the command window.

A First Program in Java: Printing a Line of Text The entire line 9, including System.out.println, the argument "Welcome to Java Programming!" in the parentheses and the semicolon (;), is called a statement.