Upload
rajkale100
View
223
Download
0
Embed Size (px)
Citation preview
8/12/2019 Java Lect 01
1/12
Welcome to the Lecture
Series on
Introduction to Programming
With Java
8/12/2019 Java Lect 01
2/12
Structure of Java programs
Input and output to screen with Java program
Statements
Conditional statements
Loop constructs
Arrays, character and string handling
Functions (if time permits)
Syllabus
8/12/2019 Java Lect 01
3/12
1. Java 2: The Complete Reference
Patrick Naughton, Herbert Schildt
2. Thinking in Java (http://www.mindview.net/Books/TIJ/)
Bruce Eckel
3. Richard G Baldwins Introductory Java ProgrammingTutorial on: http://www.dickbaldwin.com/tocint.htm
Books & References
8/12/2019 Java Lect 01
4/12
Structure of Java programs
Compiling and running the program
Printing messages to the screen
Contents for Todays Lecture
8/12/2019 Java Lect 01
5/12
Some Basics
Q. What is a program?
Ans.A sequence of instructions that a computer can interpret
and execute.
Q. Why Java and not Hindi / Marathi / English?
Ans.Since,so far, computer is not intelligent enough to
understand natural languages.
8/12/2019 Java Lect 01
6/12
class class-name{
public static void main(String args[]) {
statement1;
statement2;
}
}
Structure of Java Programs
8/12/2019 Java Lect 01
7/12 [email protected]
First.java
class First {
public static void main(String args[]) {
System.out.println(Hello World);
}
}
Example Program
8/12/2019 Java Lect 01
8/12 [email protected]
Compiling:is the process of translating source code written in
a particular programming language into computer-readable
machine code that can be executed.
$ javac First.java
This command will produce a file First.class, which is used
for running the program with the command java.
Running:is the process of executing program on a computer.
$ java First
Compiling & Running the Program
8/12/2019 Java Lect 01
9/12
1. System.out.println(Hello World); outputs the string
Hello World followed by a new line on the screen.
2. System.out.print(Hello World); - outputs the string Hello
World on the screen. This string is notfollowed by a new
line.
3. Some Escape Sequence
\nstands for new line character
\tstands for tab character
About Printing on the Screen
8/12/2019 Java Lect 01
10/12
Some common errors in the initial phase of learning
programming:
- Mismatch of parentheses
- Missing ; at the end of statement
- Case sensitivity
The best way to learn programming is writing a lot ofprograms on your own.
Some Tips About Programming
8/12/2019 Java Lect 01
11/12
1. Write a program which prints the following informationabout at least 5 persons:
NAME MAIL-ID EMPLOYEE-CODE PHONE
Eg. Umesh umesh@cse p03161 25764728
Salil salil@cse p03160 25764728
Each entry should be on a separate line.
2. Write a program that prints the following line on the screen
along with quotes.
Can we print \ with System.out.println() statement?
Some Assignments
mailto:umesh@csemailto:salil@csemailto:salil@csemailto:umesh@cse8/12/2019 Java Lect 01
12/12