Presentation is loading. Please wait.

Presentation is loading. Please wait.

Using Java MINISTRY OF EDUCATION & HIGHER EDUCATION COLLEGE OF SCIENCE AND TECHNOLOGY KHANYOUNIS- PALESTINE.

Similar presentations


Presentation on theme: "Using Java MINISTRY OF EDUCATION & HIGHER EDUCATION COLLEGE OF SCIENCE AND TECHNOLOGY KHANYOUNIS- PALESTINE."— Presentation transcript:

1 Using Java MINISTRY OF EDUCATION & HIGHER EDUCATION COLLEGE OF SCIENCE AND TECHNOLOGY KHANYOUNIS- PALESTINE

2  First Program in Java  Discussion of the main concepts  Install the JDK and JCreator  Memory Concepts and Data Types  Variables and Identifiers  Arithmetic Operations  Emank X Mezank 2 Presented & Prepared by: Mahmoud R. Alfarra

3  Computer programmers create applications by writing computer programs.  Your e-mail application helps you send and receive e-mail  your Web browser lets you view Web pages from Web sites around the world.  A Java application is a computer program that executes when you use the java command to launch the Java Virtual Machine (JVM). 3 Presented & Prepared by: Mahmoud R. Alfarra

4  Let us consider a simple application that displays a line of text using Java command. 4 Presented & Prepared by: Mahmoud R. Alfarra

5  Every program in Java consists of at least one class declaration that is defined by the programmer.  These are known as programmer-defined classes or user-defined classes. 5 Presented & Prepared by: Mahmoud R. Alfarra

6  Java class declarations normally contain one or more methods.  For a Java application, exactly one of the methods must be called main and must be defined as shown 6 Presented & Prepared by: Mahmoud R. Alfarra It is a syntax error if braces do not occur in matching pairs

7  Instructions perform an action namely, to print the string of characters contained between the double quotation marks.  We refer to characters between double quotation marks simply as strings. 7 Presented & Prepared by: Mahmoud R. Alfarra

8  Method System.out.println displays a line of text in the command window.  The string in the parentheses is the argument to the method. 8 Presented & Prepared by: Mahmoud R. Alfarra  Method print displays one line of text in the command window and position the cursor next the last character.  Println position the output cursor at the beginning of the next line in the command.

9  begins with // or between /* */, indicating that the remainder of the line is a comment.  The Java compiler ignores comments. 9 Presented & Prepared by: Mahmoud R. Alfarra

10 10 Presented & Prepared by: Mahmoud R. Alfarra Java is case sensitive. Not using the proper uppercase and lowercase letters for an identifier normally causes a compilation error. It is an error for a public class to have a file name that is not identical to the class name (plus the.java extension) in terms of both spelling and capitalization. Omitting the semicolon at the end of a statement is a syntax error.

11  From the sun site ▪ http://java.sun.com/javase/downloads/index.jsp. http://java.sun.com/javase/downloads/index.jsp  download jdk-6-windows-i586.exe  Setup normally (next then next …)  But be care where it will be installed in your PC 11 Presented & Prepared by: Mahmoud R. Alfarra

12 12 Presented & Prepared by: Mahmoud R. Alfarra  From the site of Jcreator or my web site ▪ http://www.jcreator.com/ http://www.jcreator.com/ ▪ Staff.cst.ps/mfarra  Download the JCreator Pro  And then trace the following slides to setup …

13 إعداد / أ. محمود رفيق حمدي الفرا 2010- 2011

14

15

16

17

18 1 2 3 4

19 5 6

20 7 Install the JDK and JCreator on your PC at home, and then write a program that prints your name, ID, GPA, address HW 4.1

21  Identifiers are names used to identify variables, methods, classes …  An identifier consist of letters,numbers, _, $  But must:  Begin with letter.  not contain space.  not a reserved word 21 Presented & Prepared by: Mahmoud R. Alfarra

22  A variable is a location in the computer's memory where a value can be stored for use later in a program.  All variables must be declared with a name and a type before they can be used. 22 Presented & Prepared by: Mahmoud R. Alfarra Data typeIdentifiers

23  Data types in Java are divided into two categories primitive types and reference.  A primitive-type variable can store exactly one value of its declared type at a time.  Every variable has a name, a type, a size and a value. 23 Presented & Prepared by: Mahmoud R. Alfarra

24 24 Presented & Prepared by: Mahmoud R. Alfarra 0 0 0 0 0 0 1 1 1 1 1 1 0 0 0 0 مقطع من الذكرة بمجرد هذا التعريف يتم تخصيص مساحة في الذاكرة لتخزين بيانات بحجم يناسب النوع المراد Type1 x = 28 ; // سيتم تخصيص مساحة في الذاكرة سعتها 1 بايت Type2 y; // سيتم تخصيص مساحة في الذاكرة سعتها 2 بايت Type1 x = 28 ; // سيتم تخصيص مساحة في الذاكرة سعتها 1 بايت Type2 y; // سيتم تخصيص مساحة في الذاكرة سعتها 2 بايت

25 25 Presented & Prepared by: Mahmoud R. Alfarra TypeValues examplesSize boolean true, false 1 Byte char ‘b’, ‘c’, ‘t’, ‘5’, … 2 byte byte 128, 0, 34, … 1 byte short 32768, 67, 34 2 byte int 2147483648, 7, 9, 0, … 4 byte long 9223372036854775808, 878, … 8 byte float - 3.5, 234.56, … 4 byte double -2345.34, … 8 byte

26  Most programs perform arithmetic calculations.  The arithmetic operators are 26 Presented & Prepared by: Mahmoud R. Alfarra

27  Java applies the operators in arithmetic expressions in a precise sequence determined by the following rules of operator precedence: 27 Presented & Prepared by: Mahmoud R. Alfarra

28 28 Presented & Prepared by: Mahmoud R. Alfarra

29 29 Presented & Prepared by: Mahmoud R. Alfarra

30 30 Presented & Prepared by: Mahmoud R. Alfarra Some common escape sequences

31 31 Presented & Prepared by: Mahmoud R. Alfarra

32 32 Presented & Prepared by: Mahmoud R. Alfarra

33 33 Presented & Prepared by: Mahmoud R. Alfarra

34 34 Presented & Prepared by: Mahmoud R. Alfarra

35 قال الله تعالى‏:‏ ‏ (‏لا تَجِدُ قَوماً يُؤمِنونَ بِاللَهِ وَاليَومِ الأَخِرِ يُوادّونَ مَن حادَّ اللَهَ وَرَسولَهُ) 35 Presented & Prepared by: Mahmoud R. Alfarra

36 Introduction to OOP 36 Presented & Prepared by: Mahmoud R. Alfarra


Download ppt "Using Java MINISTRY OF EDUCATION & HIGHER EDUCATION COLLEGE OF SCIENCE AND TECHNOLOGY KHANYOUNIS- PALESTINE."

Similar presentations


Ads by Google