Basic Elements Of Java Language
-
Upload
thomas-alvarez -
Category
Documents
-
view
32 -
download
0
description
Transcript of Basic Elements Of Java Language
Basic Elements Of Java Language
for more lectures and notes visit www.basicsofprogramming.wordpress.com
Variables
Storage name of particular data type having specific value. They declares under specific daa type it may be
Integer (example 0,1,2 or- 47 etc ) Boolean (example may be true or false) Double (10.2, 1.1 or -2.1 etc) String (shows text format e.g “JAVA", Pakistan etc they are strings)
for more lectures and notes visit www.basicsofprogramming.wordpress.com
Operators
Those symbols perform simple calculation. Addition + Subtraction - Multiplication * Division / && (and) e.g (1 < x) && (x < 100) || (or) e.g (lightsOn) || (isDayTime) ! (not) e.g !(isStopped)
for more lectures and notes visit www.basicsofprogramming.wordpress.com
Shortcut Assignment operators
for more lectures and notes visit www.basicsofprogramming.wordpress.com
Operator Example Equivalent
+= i+=8 i = i+8
-= f-=8.0 f = f-8.0
*= i*=8 i = i*8
/= i/=8 i = i/8
%= i%=8 i = i%8
Arithmetic Expressions
for more lectures and notes visit www.basicsofprogramming.wordpress.com
3+4x _ 10(y-5) (a+b+c) + 9 4 9+x 5 x x y
In code It well be translated like:
(3+4*x)/5 – 10*(y-5)*(a+b+c)/x + 9*(4/x + (9+x)/y)
Unicode Format
• Description Escape Sequence Unicode
• Backspace \b \u0008
• Tab \t \u0009
• Linefeed \n \u000a
• Carriage return \r \u000d
for more lectures and notes visit www.basicsofprogramming.wordpress.com
for more lectures and notes visit www.basicsofprogramming.wordpress.com
Comparison Operators
• Operator Name
• < less than
• <= less than or equal to
• > greater than
• >= greater than or equal to
• == equal to
• != not equal to
Commenting
Single Line We need forward slashes // for single line commenting. for example
// this is a single line comment
Multiple Line We use /* in first line and at the end line */ For example
/* this is multiple line comment Second line Third line And last one */
for more lectures and notes visit www.basicsofprogramming.wordpress.com
Try First Program
Import acm.graphics.*;
Import acm.program.*;
Public class FirestProgram extends GraphicsProgram {
Public void run() {
Add{ new GLabel {“My First Program”,100,75}};
}
}
for more lectures and notes visit www.basicsofprogramming.wordpress.com
END LECTURE # 3
Thanks
For next lecture (online, ppt or doc file)visit our website www.basicsofprogramming.wordpress.com
for more lectures and notes visit www.basicsofprogramming.wordpress.com