SlideShare a Scribd company logo
1 of 34
Introduction to
Java Programming, 4E
Vibrant Technologies & Computers
2
Course Objectives
Upon completing the course, you will understand
– Create, compile, and run Java programs
– Primitive data types
– Java control flow
– Methods
– Arrays (for teaching Java in two semesters, this could be the end)
– Object-oriented programming
– Core Java classes (Swing, exception, internationalization,
multithreading, multimedia, I/O, networking, Java
Collections Framework)
3
Course Objectives, cont.
You will be able to
– Develop programs using Forte
– Write simple programs using primitive data
types, control statements, methods, and arrays.
– Create and use methods
– Develop a GUI interface and Java applets
– Write interesting projects
– Establish a firm foundation on Java concepts
4
Chapters
Part I: Fundamentals of Programming
– Chapter 1 Introduction to Java
– Chapter 2 Primitive Data Types and Operations
– Chapter 3 Control Statements
– Chapter 4 Methods
– Chapter 5 Arrays
5
Book Chapters, cont.
Part II: Object-Oriented Programming
– Chapter 6 Objects and Classes
– Chapter 7 Strings
– Chapter 8 Class Inheritance and Interfaces
– Chapter 9 Object-Oriented Software Development
6
Book Chapters, cont.
Part III: GUI Programming
– Chapter 10 Getting Started with GUI Programming
– Chapter 11 Creating User Interfaces
– Chapter 12 Applets and Advanced GUI
7
Book Chapters, cont.
Part IV: Developing Comprehensive Projects
– Chapter 13 Exception Handling
– Chapter 14 Internationalization
– Chapter 15 Multithreading
– Chapter 16 Multimedia
– Chapter 17 Input and Output
– Chapter 18 Networking
– Chapter 19 Java Data Structures
8
Chapter 1 Introduction to Java
and Forte
What Is Java?
Getting Started With Java Programming
– Create, Compile and Running a Java
Application
9
What Is Java?
History
Characteristics of Java
10
History
James Gosling and Sun Microsystems
Oak
Java, May 20, 1995, Sun World
HotJava
– The first Java-enabled Web browser
JDK Evolutions
J2SE, J2ME, and J2EE (not mentioned in the
book, but could discuss here optionally)
11
Characteristics of Java
Java is simple
Java is object-oriented
Java is distributed
Java is interpreted
Java is robust
Java is secure
Java is architecture-neutral
Java is portable
Java’s performance
Java is multithreaded
Java is dynamic
12
JDK Versions
JDK 1.02 (1995)
JDK 1.1 (1996)
Java 2 SDK v 1.2 (a.k.a JDK 1.2, 1998)
Java 2 SDK v 1.3 (a.k.a JDK 1.3, 2000)
Java 2 SDK v 1.4 (a.k.a JDK 1.4, 2002)
13
JDK Editions
Java Standard Edition (J2SE)
– J2SE can be used to develop client-side standalone
applications or applets.
Java Enterprise Edition (J2EE)
– J2EE can be used to develop server-side applications
such as Java servlets and Java ServerPages.
Java Micro Edition (J2ME).
– J2ME can be used to develop applications for mobile
devices such as cell phones.
This book uses J2SE to introduce Java
programming.
14
Java IDE Tools
Forte by Sun MicroSystems
Borland JBuilder
Microsoft Visual J++
WebGain Café
IBM Visual Age for Java
15
Getting Started with Java
Programming
A Simple Java Application
Compiling Programs
Executing Applications
16
A Simple Application
Example 1.1
//This application program prints Welcome
//to Java!
package chapter1;
public class Welcome {
public static void main(String[] args) {
System.out.println("Welcome to Java!");
}
}
RunRunSourceSource
NOTE: To run the program,
install slide files on hard
disk.
17
Creating and Compiling Programs
On command line
– javac file.java Source Code
Create/Modify Source Code
Compile Source Code
i.e. javac Welcome.java
Bytecode
Run Byteode
i.e. java Welcome
Result
If compilation errors
If runtime errors or incorrect result
18
Executing Applications
On command line
– java classname
Java
Interpreter
on Windows
Java
Interpreter
on Sun Solaris
Java
Interpreter
on Linux
Bytecode
...
19
Example
javac Welcome.java
java Welcome
output:...
20
Compiling and Running a Program
Where are the files
stored in the
directory?c:example
chapter1 Welcome.class
Welcome.java
chapter2
.
.
.
Java source files and class files for Chapter 2
chapter19 Java source files and class files for Chapter 19
Welcome.java~
21
Anatomy of a Java Program
Comments
Package
Reserved words
Modifiers
Statements
Blocks
Classes
Methods
The main method
22
Comments
In Java, comments are
preceded by two slashes (//)
in a line, or enclosed
between /* and */ in one or
multiple lines. When the
compiler sees //, it ignores
all text after // in the
same line. When it sees /*,
23
Package
The second line in the program
(package chapter1;) specifies a package
name, chapter1, for the class Welcome.
Forte compiles the source code in
Welcome.java, generates
Welcome.class, and stores
Welcome.class in the chapter1 folder.
24
Reserved Words
Reserved words or keywords are
words that have a specific
meaning to the compiler and
cannot be used for other
purposes in the program. For
example, when the compiler sees
the word class, it understands
that the word after class is the
name for the class. Other
reserved words in Example 1.1
25
Modifiers
Java uses certain reserved words called
modifiers that specify the properties of the
data, methods, and classes and how they
can be used. Examples of modifiers are
public and static. Other modifiers are
private, final, abstract, and protected. A
public datum, method, or class can be
accessed by other programs. A private
datum or method cannot be accessed by
other programs. Modifiers are discussed in
Chapter 6, "Objects and Classes."
26
Statements
A statement represents an
action or a sequence of
actions. The statement
System.out.println("Welcome
to Java!") in the program in
Example 1.1 is a statement
to display the greeting
"Welcome to Java!" Every
statement in Java ends with
27
Blocks
A pair of braces in a program
forms a block that groups
components of a program.
public class Test {
public static void main(String[] args) {
System.out.println("Welcome to Java!");
}
}
Class block
Method block
28
Classes
The class is the essential Java
construct. A class is a template
or blueprint for objects. To
program in Java, you must
understand classes and be able
to write and use them. The
mystery of the class will
continue to be unveiled
throughout this book. For now,
though, understand that a
29
Methods
What is System.out.println? It is a method: a
collection of statements that performs a
sequence of operations to display a
message on the console. It can be used
even without fully understanding the
details of how it works. It is used by
invoking a statement with a string
argument. The string argument is enclosed
within parentheses. In this case, the
argument is "Welcome to Java!" You can
call the same println method with a
30
main Method
The main method provides the
control of program flow. The
Java interpreter executes the
application by invoking the main
method.
The main method looks like this:
public static void main(String[]
args) {
31
Displaying Text in a Message
Dialog Box
you can use the showMessageDialog
method in the JOptionPane class.
JOptionPane is one of the many
predefined classes in the Java system,
which can be reused rather than
“reinventing the wheel.”
RunRunSourceSource
32
The showMessageDialog Method
JOptionPane.showMessageDialog(null, "Welcome
to Java!",
"Example 1.2",
JOptionPane.INFORMATION_MESSAGE));
33
The exit Method
Use Exit to terminate the program and stop
all threads.
NOTE: When your program starts, a thread
is spawned to run the program. When the
showMessageDialog is invoked, a separate
thread is spawned to run this method. The
thread is not terminated even you close the
dialog box. To terminate the thread, you
have to invoke the exit method.
34
For more vist:
http://www.vibranttechnologies.co.in/java-classes-in-mumbai.html
Thank
You !!!

More Related Content

What's hot (20)

Java program structure
Java program structureJava program structure
Java program structure
 
5.interface and packages
5.interface and packages5.interface and packages
5.interface and packages
 
Getting Program Input
Getting Program Input Getting Program Input
Getting Program Input
 
Packages and interfaces
Packages and interfacesPackages and interfaces
Packages and interfaces
 
Introduction to java technology
Introduction to java technologyIntroduction to java technology
Introduction to java technology
 
Java programming course for beginners
Java programming course for beginnersJava programming course for beginners
Java programming course for beginners
 
Java package
Java packageJava package
Java package
 
java interface and packages
java interface and packagesjava interface and packages
java interface and packages
 
Java Presentation For Syntax
Java Presentation For SyntaxJava Presentation For Syntax
Java Presentation For Syntax
 
Java Notes
Java Notes Java Notes
Java Notes
 
Java features
Java featuresJava features
Java features
 
Java 9 Module System
Java 9 Module SystemJava 9 Module System
Java 9 Module System
 
Packages,interfaces and exceptions
Packages,interfaces and exceptionsPackages,interfaces and exceptions
Packages,interfaces and exceptions
 
Introduction to java
Introduction to  javaIntroduction to  java
Introduction to java
 
Java basics notes
Java basics notesJava basics notes
Java basics notes
 
Introduction to java
Introduction to javaIntroduction to java
Introduction to java
 
Java - Interfaces & Packages
Java - Interfaces & PackagesJava - Interfaces & Packages
Java - Interfaces & Packages
 
Ppt chapter07
Ppt chapter07Ppt chapter07
Ppt chapter07
 
JAVA Object Oriented Programming (OOP)
JAVA Object Oriented Programming (OOP)JAVA Object Oriented Programming (OOP)
JAVA Object Oriented Programming (OOP)
 
Core java online training
Core java online trainingCore java online training
Core java online training
 

Viewers also liked

Universidad de guadalajara
Universidad de guadalajaraUniversidad de guadalajara
Universidad de guadalajaraNoemi Buendia
 
Lifestyle Segmentation Tatyana Zheltomirskaya Brandspoint10
Lifestyle Segmentation Tatyana Zheltomirskaya Brandspoint10Lifestyle Segmentation Tatyana Zheltomirskaya Brandspoint10
Lifestyle Segmentation Tatyana Zheltomirskaya Brandspoint10BrandsPoint
 
VAB Alex Garmash Brandspoint10
VAB Alex Garmash Brandspoint10VAB Alex Garmash Brandspoint10
VAB Alex Garmash Brandspoint10BrandsPoint
 
Бизнес-игра как pr-инструмент
Бизнес-игра как pr-инструментБизнес-игра как pr-инструмент
Бизнес-игра как pr-инструментAleksey Potapenko
 
Intranet Presentation
Intranet PresentationIntranet Presentation
Intranet Presentationrenaglasser
 
Taiwanese culture by Kate, Sarena & Shawn
Taiwanese culture by Kate, Sarena & ShawnTaiwanese culture by Kate, Sarena & Shawn
Taiwanese culture by Kate, Sarena & Shawnguest3aad71
 
Intestinal flagellates. j.h.c
Intestinal flagellates. j.h.cIntestinal flagellates. j.h.c
Intestinal flagellates. j.h.cNoe Mendez
 
Food Chains and Food Webs (by: NPMendez)
Food Chains and Food Webs (by: NPMendez)Food Chains and Food Webs (by: NPMendez)
Food Chains and Food Webs (by: NPMendez)Noe Mendez
 
Tetanus-strichnine toxicity & rabies
Tetanus-strichnine toxicity & rabiesTetanus-strichnine toxicity & rabies
Tetanus-strichnine toxicity & rabiesNeurology Residency
 
Long-term effect of physical activity on energy balance and body composition
Long-term effect of physical activity on energy balance and body compositionLong-term effect of physical activity on energy balance and body composition
Long-term effect of physical activity on energy balance and body compositionjuan pedro gracia mendez
 

Viewers also liked (18)

Universidad de guadalajara
Universidad de guadalajaraUniversidad de guadalajara
Universidad de guadalajara
 
Lifestyle Segmentation Tatyana Zheltomirskaya Brandspoint10
Lifestyle Segmentation Tatyana Zheltomirskaya Brandspoint10Lifestyle Segmentation Tatyana Zheltomirskaya Brandspoint10
Lifestyle Segmentation Tatyana Zheltomirskaya Brandspoint10
 
HTML
HTMLHTML
HTML
 
ErikaHughesResume
ErikaHughesResumeErikaHughesResume
ErikaHughesResume
 
Actividad 0.1
Actividad 0.1Actividad 0.1
Actividad 0.1
 
VAB Alex Garmash Brandspoint10
VAB Alex Garmash Brandspoint10VAB Alex Garmash Brandspoint10
VAB Alex Garmash Brandspoint10
 
Бизнес-игра как pr-инструмент
Бизнес-игра как pr-инструментБизнес-игра как pr-инструмент
Бизнес-игра как pr-инструмент
 
Workshop of Business English 1
Workshop of Business English 1Workshop of Business English 1
Workshop of Business English 1
 
RESUME
RESUMERESUME
RESUME
 
Blender renata
Blender renataBlender renata
Blender renata
 
Intranet Presentation
Intranet PresentationIntranet Presentation
Intranet Presentation
 
Taiwanese culture by Kate, Sarena & Shawn
Taiwanese culture by Kate, Sarena & ShawnTaiwanese culture by Kate, Sarena & Shawn
Taiwanese culture by Kate, Sarena & Shawn
 
Intestinal flagellates. j.h.c
Intestinal flagellates. j.h.cIntestinal flagellates. j.h.c
Intestinal flagellates. j.h.c
 
Food Chains and Food Webs (by: NPMendez)
Food Chains and Food Webs (by: NPMendez)Food Chains and Food Webs (by: NPMendez)
Food Chains and Food Webs (by: NPMendez)
 
Reassessing Regulation and the IoT - Gilad Rosner
Reassessing Regulation and the IoT - Gilad RosnerReassessing Regulation and the IoT - Gilad Rosner
Reassessing Regulation and the IoT - Gilad Rosner
 
Malaria ppt
Malaria pptMalaria ppt
Malaria ppt
 
Tetanus-strichnine toxicity & rabies
Tetanus-strichnine toxicity & rabiesTetanus-strichnine toxicity & rabies
Tetanus-strichnine toxicity & rabies
 
Long-term effect of physical activity on energy balance and body composition
Long-term effect of physical activity on energy balance and body compositionLong-term effect of physical activity on energy balance and body composition
Long-term effect of physical activity on energy balance and body composition
 

Similar to Core java-introduction

Similar to Core java-introduction (20)

Java intro
Java introJava intro
Java intro
 
01slide
01slide01slide
01slide
 
01slide
01slide01slide
01slide
 
Professional-core-java-training
Professional-core-java-trainingProfessional-core-java-training
Professional-core-java-training
 
Professional-core-java-training
Professional-core-java-trainingProfessional-core-java-training
Professional-core-java-training
 
Java course-in-mumbai
Java course-in-mumbaiJava course-in-mumbai
Java course-in-mumbai
 
01slide
01slide01slide
01slide
 
Basics of java 1
Basics of java 1Basics of java 1
Basics of java 1
 
Java Standard edition(Java ) programming Basics for beginner's
Java Standard edition(Java ) programming Basics  for beginner'sJava Standard edition(Java ) programming Basics  for beginner's
Java Standard edition(Java ) programming Basics for beginner's
 
Unit of competency
Unit of competencyUnit of competency
Unit of competency
 
OOP with Java
OOP with JavaOOP with Java
OOP with Java
 
Understanding And Using Reflection
Understanding And Using ReflectionUnderstanding And Using Reflection
Understanding And Using Reflection
 
Introduction
IntroductionIntroduction
Introduction
 
Chapter 2.1
Chapter 2.1Chapter 2.1
Chapter 2.1
 
java basic for begginers
java basic for begginersjava basic for begginers
java basic for begginers
 
Top 10 Important Core Java Interview questions and answers.pdf
Top 10 Important Core Java Interview questions and answers.pdfTop 10 Important Core Java Interview questions and answers.pdf
Top 10 Important Core Java Interview questions and answers.pdf
 
Java_presesntation.ppt
Java_presesntation.pptJava_presesntation.ppt
Java_presesntation.ppt
 
Java for Mainframers
Java for MainframersJava for Mainframers
Java for Mainframers
 
Classes and Objects
Classes and ObjectsClasses and Objects
Classes and Objects
 
Java course-in-mumbai
Java course-in-mumbaiJava course-in-mumbai
Java course-in-mumbai
 

Recently uploaded

Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Class 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfClass 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfakmcokerachita
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 

Recently uploaded (20)

Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Class 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfClass 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdf
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 

Core java-introduction

  • 1. Introduction to Java Programming, 4E Vibrant Technologies & Computers
  • 2. 2 Course Objectives Upon completing the course, you will understand – Create, compile, and run Java programs – Primitive data types – Java control flow – Methods – Arrays (for teaching Java in two semesters, this could be the end) – Object-oriented programming – Core Java classes (Swing, exception, internationalization, multithreading, multimedia, I/O, networking, Java Collections Framework)
  • 3. 3 Course Objectives, cont. You will be able to – Develop programs using Forte – Write simple programs using primitive data types, control statements, methods, and arrays. – Create and use methods – Develop a GUI interface and Java applets – Write interesting projects – Establish a firm foundation on Java concepts
  • 4. 4 Chapters Part I: Fundamentals of Programming – Chapter 1 Introduction to Java – Chapter 2 Primitive Data Types and Operations – Chapter 3 Control Statements – Chapter 4 Methods – Chapter 5 Arrays
  • 5. 5 Book Chapters, cont. Part II: Object-Oriented Programming – Chapter 6 Objects and Classes – Chapter 7 Strings – Chapter 8 Class Inheritance and Interfaces – Chapter 9 Object-Oriented Software Development
  • 6. 6 Book Chapters, cont. Part III: GUI Programming – Chapter 10 Getting Started with GUI Programming – Chapter 11 Creating User Interfaces – Chapter 12 Applets and Advanced GUI
  • 7. 7 Book Chapters, cont. Part IV: Developing Comprehensive Projects – Chapter 13 Exception Handling – Chapter 14 Internationalization – Chapter 15 Multithreading – Chapter 16 Multimedia – Chapter 17 Input and Output – Chapter 18 Networking – Chapter 19 Java Data Structures
  • 8. 8 Chapter 1 Introduction to Java and Forte What Is Java? Getting Started With Java Programming – Create, Compile and Running a Java Application
  • 10. 10 History James Gosling and Sun Microsystems Oak Java, May 20, 1995, Sun World HotJava – The first Java-enabled Web browser JDK Evolutions J2SE, J2ME, and J2EE (not mentioned in the book, but could discuss here optionally)
  • 11. 11 Characteristics of Java Java is simple Java is object-oriented Java is distributed Java is interpreted Java is robust Java is secure Java is architecture-neutral Java is portable Java’s performance Java is multithreaded Java is dynamic
  • 12. 12 JDK Versions JDK 1.02 (1995) JDK 1.1 (1996) Java 2 SDK v 1.2 (a.k.a JDK 1.2, 1998) Java 2 SDK v 1.3 (a.k.a JDK 1.3, 2000) Java 2 SDK v 1.4 (a.k.a JDK 1.4, 2002)
  • 13. 13 JDK Editions Java Standard Edition (J2SE) – J2SE can be used to develop client-side standalone applications or applets. Java Enterprise Edition (J2EE) – J2EE can be used to develop server-side applications such as Java servlets and Java ServerPages. Java Micro Edition (J2ME). – J2ME can be used to develop applications for mobile devices such as cell phones. This book uses J2SE to introduce Java programming.
  • 14. 14 Java IDE Tools Forte by Sun MicroSystems Borland JBuilder Microsoft Visual J++ WebGain Café IBM Visual Age for Java
  • 15. 15 Getting Started with Java Programming A Simple Java Application Compiling Programs Executing Applications
  • 16. 16 A Simple Application Example 1.1 //This application program prints Welcome //to Java! package chapter1; public class Welcome { public static void main(String[] args) { System.out.println("Welcome to Java!"); } } RunRunSourceSource NOTE: To run the program, install slide files on hard disk.
  • 17. 17 Creating and Compiling Programs On command line – javac file.java Source Code Create/Modify Source Code Compile Source Code i.e. javac Welcome.java Bytecode Run Byteode i.e. java Welcome Result If compilation errors If runtime errors or incorrect result
  • 18. 18 Executing Applications On command line – java classname Java Interpreter on Windows Java Interpreter on Sun Solaris Java Interpreter on Linux Bytecode ...
  • 20. 20 Compiling and Running a Program Where are the files stored in the directory?c:example chapter1 Welcome.class Welcome.java chapter2 . . . Java source files and class files for Chapter 2 chapter19 Java source files and class files for Chapter 19 Welcome.java~
  • 21. 21 Anatomy of a Java Program Comments Package Reserved words Modifiers Statements Blocks Classes Methods The main method
  • 22. 22 Comments In Java, comments are preceded by two slashes (//) in a line, or enclosed between /* and */ in one or multiple lines. When the compiler sees //, it ignores all text after // in the same line. When it sees /*,
  • 23. 23 Package The second line in the program (package chapter1;) specifies a package name, chapter1, for the class Welcome. Forte compiles the source code in Welcome.java, generates Welcome.class, and stores Welcome.class in the chapter1 folder.
  • 24. 24 Reserved Words Reserved words or keywords are words that have a specific meaning to the compiler and cannot be used for other purposes in the program. For example, when the compiler sees the word class, it understands that the word after class is the name for the class. Other reserved words in Example 1.1
  • 25. 25 Modifiers Java uses certain reserved words called modifiers that specify the properties of the data, methods, and classes and how they can be used. Examples of modifiers are public and static. Other modifiers are private, final, abstract, and protected. A public datum, method, or class can be accessed by other programs. A private datum or method cannot be accessed by other programs. Modifiers are discussed in Chapter 6, "Objects and Classes."
  • 26. 26 Statements A statement represents an action or a sequence of actions. The statement System.out.println("Welcome to Java!") in the program in Example 1.1 is a statement to display the greeting "Welcome to Java!" Every statement in Java ends with
  • 27. 27 Blocks A pair of braces in a program forms a block that groups components of a program. public class Test { public static void main(String[] args) { System.out.println("Welcome to Java!"); } } Class block Method block
  • 28. 28 Classes The class is the essential Java construct. A class is a template or blueprint for objects. To program in Java, you must understand classes and be able to write and use them. The mystery of the class will continue to be unveiled throughout this book. For now, though, understand that a
  • 29. 29 Methods What is System.out.println? It is a method: a collection of statements that performs a sequence of operations to display a message on the console. It can be used even without fully understanding the details of how it works. It is used by invoking a statement with a string argument. The string argument is enclosed within parentheses. In this case, the argument is "Welcome to Java!" You can call the same println method with a
  • 30. 30 main Method The main method provides the control of program flow. The Java interpreter executes the application by invoking the main method. The main method looks like this: public static void main(String[] args) {
  • 31. 31 Displaying Text in a Message Dialog Box you can use the showMessageDialog method in the JOptionPane class. JOptionPane is one of the many predefined classes in the Java system, which can be reused rather than “reinventing the wheel.” RunRunSourceSource
  • 32. 32 The showMessageDialog Method JOptionPane.showMessageDialog(null, "Welcome to Java!", "Example 1.2", JOptionPane.INFORMATION_MESSAGE));
  • 33. 33 The exit Method Use Exit to terminate the program and stop all threads. NOTE: When your program starts, a thread is spawned to run the program. When the showMessageDialog is invoked, a separate thread is spawned to run this method. The thread is not terminated even you close the dialog box. To terminate the thread, you have to invoke the exit method.

Editor's Notes

  1. First Class: Introduction, Prerequisites, Advices, Syllabus Lab 1: Create a Java Project, Compile, and Run. Show syntax errors Print program Capture screen shots, and save it in Word, and print it. Homework One: Check in the class randomly.