Presentation is loading. Please wait.

Presentation is loading. Please wait.

“Hello World” In Java Mehdi Einali Advanced Programming in Java 1.

Similar presentations


Presentation on theme: "“Hello World” In Java Mehdi Einali Advanced Programming in Java 1."— Presentation transcript:

1 “Hello World” In Java Mehdi Einali Advanced Programming in Java 1

2 2 Agenda Review First program in java Variables Methods Conditions Loops

3 3 Review Java is Simple object oriented And popular Java is platform independent. Write Once, Run Anywhere!

4 4 Hello World Create a file named First.java Java class files have.java extension Note to naming convention Copy this lines to the file Note: File name and class name should be the same.

5 5

6 6 Debugging Syntax Error Run-time errors exceptions logic or semantic error The semantics, or meaning of the program, are wrong

7 7 Java Programs A simple java program is a file The file contains one class The class name equal to the file name The names are case sensitive The class contains a main method When we run the program, the main method is executed

8 8 Variables What is a variable? A piece of memory Holds data For example a number, string or Boolean Java variables have a fixed size Platform independence

9 9 Java Primitive Types

10 10 Arithmetic Operators

11 11 Operator Precedence 1 + 2 * 3 = ? is treated as 1 + (2 * 3)

12 12 Equality and Relational Operators

13 13 Operators

14 14 Exercise

15 15 Programming strategy Incremental Development Start with a working program that does something visible, like printing something. Add a small number of lines of code at a time, and test the program after every change. Repeat until the program does what it is supposed to do

16 16 Recipe For Failure -1 Non-incremental development If you write more than a few lines of code without compiling and testing, you are asking for trouble Attachment to bad code If you write more than a few lines of code without compiling and testing, you may not be able to debug it

17 17 Recipe For Failure -2 Random-walk programming Make a change, run the program, get an error, make a change, run the program, etc he problem is that there is no apparent connection between the outcome of the program and the change. Compiler submission Error messages are useful, but they are not always right. Please think before edit

18 18 Khokhan-1

19 19 Khokhan-2 Stubborn Crazy Untidy Stochastic Hate other khokhans And Love Chaos

20 20 end


Download ppt "“Hello World” In Java Mehdi Einali Advanced Programming in Java 1."

Similar presentations


Ads by Google