Java PPT Ch02
Java PPT Ch02
Using Data
2 Objectives
Use constants and variables
Use integer data type
Use the boolean data type
Use floating-point data types
Use the char data type
Primitive type
Simple data type
Reference types
More complex data types
Name variables
Using naming rules for legal class identifiersاستخدام قواعد التسمية لمعرفات
الفئات القانونية
Variable declaration
Statement that reserves named memory locationالعبارة التي تحتفظ
بموقع الذاكرة المسماة
Includes: يتضمن
Data type
Identifier المعرف
Optional assignment operator and assigned value عامل تشغيل التعيين االختياري
والقيمة المعينة
Ending semicolon
9
Declaring Variables
(cont'd.)
Assignment operator مهمة التشغيل
Equal sign (=)
Value to right assigned to variable on left القيمة إلى اليمين المعينة إلى المتغير على
اليسار
Initializationالتهيئه
Assignment made when declaring variable التعيين الذي تم إجراؤه عند اإلعالن عن
المتغير
Assignment مهمة
Assignment made after variable declared الذي تم إجراؤه بعد إعالن المتغير
Associativity االرتباط
Order in which operands used with operators ترتيب المعامالت المستخدمة مع
عوامل التشغيل
10 Declaring Variables
(cont'd.)
Declare multiple variables of same type in
separate statements on different lines اإلعالن
عن متغيرات متعددة من نفس النوع في عبارات منفصلة على أسطر مختلفة
Variations
االختالفاتof the integer type
byte
short
Long
Floating-point number
Contains decimal positions
Floating-point data types
float
double
Significant digits
Refers to mathematical accuracy
20 Learning About Floating-
Point Data Types (cont'd.)
JOptionPane.showMessageDialog(
)
Does not accept single numeric variable
Null String
Empty string: “”
Arithmetic operators
Perform calculations with values in programs
Operand
Value used on either side of operator
Integer division
Integer constants or integer variables
Result is integer
Fractional part of result lost
Variables
Named memory locations
Primitive data types
Standard arithmetic operators for integers
+, _, *, /, and %
Boolean type
true or false value
Relational operators
>, <, ==, >=, <=, and !=