Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Lecture # 2. * Introducing Programming with an Example * Identifiers, Variables, and Constants * Primitive Data Types * Byte, short, int, long, float,

Similar presentations


Presentation on theme: "1 Lecture # 2. * Introducing Programming with an Example * Identifiers, Variables, and Constants * Primitive Data Types * Byte, short, int, long, float,"— Presentation transcript:

1 1 Lecture # 2

2 * Introducing Programming with an Example * Identifiers, Variables, and Constants * Primitive Data Types * Byte, short, int, long, float, double, char, boolean * Operators * +, -, *, /, %, +=, -=, *=, /=, %=, ++, -- * Expressions 2 Lecture # 2

3 Class myProgram { public static void main(Strings arg[]) { System.out.println(“My First Java Program”); } Simple Java Code 3 Lecture # 2

4 Class myProgram { } This is the Base Class of Code where Main Function is Located 4 Lecture # 2

5 This is the Main Function of Program the compiler would start the compilation from this Main Function public static void main(Strings arg[]) { } 5 Lecture # 2

6 System.out.println(“My First Java Program”); A simple Print Java Statement 6 Lecture # 2

7

8 int x; // Declare x to be an // integer variable; double radius; // Declare radius to // be a double variable; char a; // Declare a to be a // character variable;

9 x = 1; // Assign 1 to x; radius = 1.0; // Assign 1.0 to radius; a = 'A'; // Assign 'A' to a;

10 * int x = 1; * double d = 1.4; * float f = 1.4;

11 final datatype CONSTANTNAME = VALUE; final double PI = 3.14159; final int SIZE = 3;

12 +, -, *, /, and % 5/2 yields an integer 2. 5.0/2 yields a double value 2.5 5 % 2 yields 1 (the remainder of the division)

13 OperatorExampleEquivalent +=i+=8i = i+8 -=f-=8.0f = f-8.0 *=i*=8i = i*8 /=i/=8i = i/8 %=i%=8i = i%8

14 * x = 1; * y = 1 + x++; * y = 1 + ++x; * y = 1 + x--; * y = 1 + --x;

15 char letter = 'A'; char numChar = '4'; Special characters char tab = ‘\t’;

16 boolean lightsOn = true; boolean lightsOn = false;

17 Lecture # 2 17


Download ppt "1 Lecture # 2. * Introducing Programming with an Example * Identifiers, Variables, and Constants * Primitive Data Types * Byte, short, int, long, float,"

Similar presentations


Ads by Google