SlideShare ist ein Scribd-Unternehmen logo
1 von 34
Introduction to
Java Programming, 4E

    Y. Daniel Liang
Introduction
3 Course Objectives
3 Organization of the Book




                             2
Course Objectives
3   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.
3   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
Book Chapters
3   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.
3   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.
3   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.
3   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
3 What Is Java?
3 Getting Started With Java Programming
    – Create, Compile and Running a Java
      Application




                                           9
What Is Java?
3   History
3   Characteristics of Java




                               10
History
3   James Gosling and Sun Microsystems
3   Oak
3   Java, May 20, 1995, Sun World
3   HotJava
    – The first Java-enabled Web browser
3   JDK Evolutions
3   J2SE, J2ME, and J2EE (not mentioned in the
    book, but could discuss here optionally)
                                            11
Characteristics of Java
3   Java is simple
3   Java is object-oriented
3   Java is distributed
3   Java is interpreted
3   Java is robust
3   Java is secure
3   Java is architecture-neutral
3   Java is portable
3   Java’s performance
3   Java is multithreaded
3   Java is dynamic

                                       12
JDK Versions
3   JDK 1.02 (1995)
3   JDK 1.1 (1996)
3   Java 2 SDK v 1.2 (a.k.a JDK 1.2, 1998)
3   Java 2 SDK v 1.3 (a.k.a JDK 1.3, 2000)
3   Java 2 SDK v 1.4 (a.k.a JDK 1.4, 2002)




                                             13
JDK Editions
3   Java Standard Edition (J2SE)
    – J2SE can be used to develop client-side standalone
      applications or applets.
3   Java Enterprise Edition (J2EE)
    – J2EE can be used to develop server-side applications
      such as Java servlets and Java ServerPages.
3   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
3   Forte by Sun MicroSystems
3   Borland JBuilder
3   Microsoft Visual J++
3   WebGain Café
3   IBM Visual Age for Java




                                15
Getting Started with Java
             Programming
3A   Simple Java Application
3 Compiling   Programs
3 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!");
  }
}
       Source                   Run
                       NOTE: To run the program,
                         install slide files on hard
                         disk.                         17
Creating and Compiling Programs
                        Create/Modify Source Code

3   On command line
    – javac file.java
                              Source Code




                          Compile Source Code
                         i.e. javac Welcome.java

                                       If compilation errors




                                Bytecode




                               Run Byteode
                            i.e. java Welcome




                                 Result




                                       If runtime errors or incorrect result


                                                                          18
Executing Applications
3   On command line
    – java classname


                                 Bytecode




        Java          Java                             Java
     Interpreter   Interpreter                      Interpreter
                                            ...
    on Windows      on Linux                      on Sun Solaris




                                                                   19
Example
javac Welcome.java

java Welcome

output:...




                         20
Compiling and Running a Program
                                                              Where are the files
                                 Welcome.java
                                                              stored in the
c:example                                                    directory?
                 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




                                                                                21
Anatomy of a Java Program
3 Comments
3 Package
3 Reserved words
3 Modifiers
3 Statements
3 Blocks
3 Classes
3 Methods
3 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 {
                                                               Class block
    public static void main(String[] args) {
      System.out.println("Welcome to Java!");   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.”
        Source            Run
                                     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

Weitere ähnliche Inhalte

Was ist angesagt?

Introducción a la progrogramación orientada a objetos con Java
Introducción a la progrogramación orientada a objetos con JavaIntroducción a la progrogramación orientada a objetos con Java
Introducción a la progrogramación orientada a objetos con JavaFacultad de Ciencias y Sistemas
 
Introduction to java
Introduction to javaIntroduction to java
Introduction to javajayc8586
 
Introduction to java
Introduction to java Introduction to java
Introduction to java Java Lover
 
Introduction to Java Programming
Introduction to Java Programming Introduction to Java Programming
Introduction to Java Programming Saravanakumar R
 
Introduction to Java Programming Language
Introduction to Java Programming LanguageIntroduction to Java Programming Language
Introduction to Java Programming Languagejaimefrozr
 
1 Introduction To Java Technology
1 Introduction To Java Technology 1 Introduction To Java Technology
1 Introduction To Java Technology dM Technologies
 
Java Lecture 1
Java Lecture 1Java Lecture 1
Java Lecture 1Qualys
 
Training on java niit (sahil gupta 9068557926)
Training on java niit (sahil gupta 9068557926)Training on java niit (sahil gupta 9068557926)
Training on java niit (sahil gupta 9068557926)Sahil Gupta
 

Was ist angesagt? (19)

Introducción a la progrogramación orientada a objetos con Java
Introducción a la progrogramación orientada a objetos con JavaIntroducción a la progrogramación orientada a objetos con Java
Introducción a la progrogramación orientada a objetos con Java
 
Introduction to java
Introduction to javaIntroduction to java
Introduction to java
 
Java basics notes
Java basics notesJava basics notes
Java basics notes
 
Java notes
Java notesJava notes
Java notes
 
Introduction to java
Introduction to java Introduction to java
Introduction to java
 
Introduction to Java Programming
Introduction to Java Programming Introduction to Java Programming
Introduction to Java Programming
 
JAVA Program Examples
JAVA Program ExamplesJAVA Program Examples
JAVA Program Examples
 
Introduction to Java Programming Language
Introduction to Java Programming LanguageIntroduction to Java Programming Language
Introduction to Java Programming Language
 
Learn Java Part 1
Learn Java Part 1Learn Java Part 1
Learn Java Part 1
 
1 Introduction To Java Technology
1 Introduction To Java Technology 1 Introduction To Java Technology
1 Introduction To Java Technology
 
Java programming course for beginners
Java programming course for beginnersJava programming course for beginners
Java programming course for beginners
 
Java Lecture 1
Java Lecture 1Java Lecture 1
Java Lecture 1
 
Java essential notes
Java essential notesJava essential notes
Java essential notes
 
Java ms harsha
Java ms harshaJava ms harsha
Java ms harsha
 
Java Notes
Java Notes Java Notes
Java Notes
 
Core java tutorial
Core java tutorialCore java tutorial
Core java tutorial
 
Training on java niit (sahil gupta 9068557926)
Training on java niit (sahil gupta 9068557926)Training on java niit (sahil gupta 9068557926)
Training on java niit (sahil gupta 9068557926)
 
Introducing Java 7
Introducing Java 7Introducing Java 7
Introducing Java 7
 
Features of java
Features of javaFeatures of java
Features of java
 

Andere mochten auch

Andere mochten auch (7)

01slide
01slide01slide
01slide
 
Computer science education week or csed week
Computer science education week or csed weekComputer science education week or csed week
Computer science education week or csed week
 
JavaYDL16
JavaYDL16JavaYDL16
JavaYDL16
 
JavaYDL3
JavaYDL3JavaYDL3
JavaYDL3
 
JavaYDL5
JavaYDL5JavaYDL5
JavaYDL5
 
JavaYDL4
JavaYDL4JavaYDL4
JavaYDL4
 
JavaYDL6
JavaYDL6JavaYDL6
JavaYDL6
 

Ähnlich wie 01slide

Ähnlich wie 01slide (20)

Core java-introduction
Core java-introductionCore java-introduction
Core java-introduction
 
01slide
01slide01slide
01slide
 
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
 
01slide (1)ffgfefge
01slide (1)ffgfefge01slide (1)ffgfefge
01slide (1)ffgfefge
 
Java intro
Java introJava intro
Java intro
 
Java course-in-mumbai
Java course-in-mumbaiJava course-in-mumbai
Java course-in-mumbai
 
OOP with Java
OOP with JavaOOP with Java
OOP with Java
 
01slide
01slide01slide
01slide
 
01slide
01slide01slide
01slide
 
Basics of java 1
Basics of java 1Basics of java 1
Basics of java 1
 
Professional-core-java-training
Professional-core-java-trainingProfessional-core-java-training
Professional-core-java-training
 
Java introduction
Java introductionJava introduction
Java introduction
 
CORE JAVA
CORE JAVACORE JAVA
CORE JAVA
 
Introduction to Java Programming, Basic Structure, variables Data type, input...
Introduction to Java Programming, Basic Structure, variables Data type, input...Introduction to Java Programming, Basic Structure, variables Data type, input...
Introduction to Java Programming, Basic Structure, variables Data type, input...
 
Java chapter 1
Java   chapter 1Java   chapter 1
Java chapter 1
 
Unit of competency
Unit of competencyUnit of competency
Unit of competency
 
Chapter 1.3
Chapter 1.3Chapter 1.3
Chapter 1.3
 
Elements of Java Language
Elements of Java Language Elements of Java Language
Elements of Java Language
 
Intoduction to java
Intoduction to javaIntoduction to java
Intoduction to java
 
Dr. Rajeshree Khande :Intoduction to java
Dr. Rajeshree Khande :Intoduction to javaDr. Rajeshree Khande :Intoduction to java
Dr. Rajeshree Khande :Intoduction to java
 

Kürzlich hochgeladen

08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 

Kürzlich hochgeladen (20)

08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 

01slide

  • 2. Introduction 3 Course Objectives 3 Organization of the Book 2
  • 3. Course Objectives 3 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
  • 4. Course Objectives, cont. 3 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
  • 5. Book Chapters 3 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
  • 6. Book Chapters, cont. 3 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
  • 7. Book Chapters, cont. 3 Part III: GUI Programming – Chapter 10 Getting Started with GUI Programming – Chapter 11 Creating User Interfaces – Chapter 12 Applets and Advanced GUI 7
  • 8. Book Chapters, cont. 3 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
  • 9. Chapter 1 Introduction to Java and Forte 3 What Is Java? 3 Getting Started With Java Programming – Create, Compile and Running a Java Application 9
  • 10. What Is Java? 3 History 3 Characteristics of Java 10
  • 11. History 3 James Gosling and Sun Microsystems 3 Oak 3 Java, May 20, 1995, Sun World 3 HotJava – The first Java-enabled Web browser 3 JDK Evolutions 3 J2SE, J2ME, and J2EE (not mentioned in the book, but could discuss here optionally) 11
  • 12. Characteristics of Java 3 Java is simple 3 Java is object-oriented 3 Java is distributed 3 Java is interpreted 3 Java is robust 3 Java is secure 3 Java is architecture-neutral 3 Java is portable 3 Java’s performance 3 Java is multithreaded 3 Java is dynamic 12
  • 13. JDK Versions 3 JDK 1.02 (1995) 3 JDK 1.1 (1996) 3 Java 2 SDK v 1.2 (a.k.a JDK 1.2, 1998) 3 Java 2 SDK v 1.3 (a.k.a JDK 1.3, 2000) 3 Java 2 SDK v 1.4 (a.k.a JDK 1.4, 2002) 13
  • 14. JDK Editions 3 Java Standard Edition (J2SE) – J2SE can be used to develop client-side standalone applications or applets. 3 Java Enterprise Edition (J2EE) – J2EE can be used to develop server-side applications such as Java servlets and Java ServerPages. 3 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
  • 15. Java IDE Tools 3 Forte by Sun MicroSystems 3 Borland JBuilder 3 Microsoft Visual J++ 3 WebGain Café 3 IBM Visual Age for Java 15
  • 16. Getting Started with Java Programming 3A Simple Java Application 3 Compiling Programs 3 Executing Applications 16
  • 17. 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!"); } } Source Run NOTE: To run the program, install slide files on hard disk. 17
  • 18. Creating and Compiling Programs Create/Modify Source Code 3 On command line – javac file.java Source Code Compile Source Code i.e. javac Welcome.java If compilation errors Bytecode Run Byteode i.e. java Welcome Result If runtime errors or incorrect result 18
  • 19. Executing Applications 3 On command line – java classname Bytecode Java Java Java Interpreter Interpreter Interpreter ... on Windows on Linux on Sun Solaris 19
  • 21. Compiling and Running a Program Where are the files Welcome.java stored in the c:example directory? 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 21
  • 22. Anatomy of a Java Program 3 Comments 3 Package 3 Reserved words 3 Modifiers 3 Statements 3 Blocks 3 Classes 3 Methods 3 The main method 22
  • 23. 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
  • 24. 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
  • 25. 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
  • 26. 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
  • 27. 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
  • 28. Blocks A pair of braces in a program forms a block that groups components of a program. public class Test { Class block public static void main(String[] args) { System.out.println("Welcome to Java!"); Method block } } 28
  • 29. 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
  • 30. 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
  • 31. 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
  • 32. 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.” Source Run 32
  • 33. The showMessageDialog Method JOptionPane.showMessageDialog(null, "Welcome to Java!", "Example 1.2", JOptionPane.INFORMATION_MESSAGE)); 33
  • 34. 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

Hinweis der Redaktion

  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.