Download
Java Applications Presentation Transcript:
1.Introduction to Java Applications
2.OBJECTIVES
In this Lecture you will learn:
Introduction to Java
Features of Java
Java code compilation steps
Introduction to Java Tools
To write simple Java applications.
3.Introduction to Java
James Gosling-1995
4.Features of JAVA
Automatic Memory Management
Performance (Just In Time Compilation)- JIT
Garbage Collector – for example (CMS).
Very strong for OOP
Platform Independent (JVM)
No -pointers, operator overloading, multiple inheritance
5.Java Code Compilation Steps
6.Introduction to Java Tools
Java development Kit (JDK 7)
Netbeans (7.0.1)
Installation instructions are available at
https://sites.google.com/a/ciitlahore.edu.pk/programmingconcepts/
7.Sample Program in Java
8.Comments
Comments start with: //
Comments ignored during program execution
Document and describe code
Provides code readability
Traditional comments: /* ... */
/* This is a traditional comment. It can be split over many lines */
Another line of comments
Note: line numbers not part of program, added for reference
9.First Program in Java: Printing a Line of Text
Blank line
Makes program more readable
Blank lines, spaces, and tabs are white-space characters
Ignored by compiler
Begins class declaration for class Welcome1
Every Java program has at least one user-defined class
Keyword: words reserved for use by Java
class keyword followed by class name
Naming classes: capitalize every word
SampleClassName
10.Java identifier
Series of characters consisting of letters, digits, underscores ( _ ) and dollar signs ( $ )
Does not begin with a digit, has no spaces
Examples: Welcome1, $value, _value, button7
7button is invalid
Java is case sensitive (capitalization matters)
a1 and A1 are different
In chapters 2 to 7, start each class with public class
Details of this covered later
11.
Saving files
File name must be class name with .java extension
Welcome1.java
Left brace {
Begins body of every class
Right brace ends declarations (line 13)
12.
Part of every Java application
Applications begin executing at main
Parentheses indicate main is a method (Ch. 3 and 6)
Java applications contain one or more methods
Exactly one method must be called main
Methods can perform tasks and return information
void means main returns no information
For now, mimic main's first line
Left brace begins body of method declaration
Ended by right brace } (line 11)
13.
Instructs computer to perform an action
Prints string of characters
String – series of characters inside double quotes
White-spaces in strings are not ignored by compiler
System.out
Standard output object
Print to command window (i.e., MS-DOS prompt)
Method System.out.println
Displays line of text
This line known as a statement
Statements must end with semicolon ;
14.
Ends method declaration
Ends class declaration
Can add comments to keep track of ending braces
15.Executing a program
Type java Welcome1
Launches JVM
JVM loads .class file for class Welcome1
.class extension omitted from command
JVM calls method main
No comments:
Post a Comment