Introduction Day 1



Download 9.83 Mb.
Page1/3
Date26.04.2018
Size9.83 Mb.
#46872
  1   2   3
Teach Yourself

Java in 21 Days

Professional Reference Edition

by Laura Lemay, Charles L. Perkins and Michael Morrison

http://www.dmc.fmph.uniba.sk/public_html/doc/Java/index.htm

C  O  N  T  E  N  T  S

Introduction

Day   An Introduction to Java Programming

  • What Is Java?

  • Java's Past, Present, and Future

  • Why Learn Java?

    • Java Is Platform Independent

    • Java Is Object Oriented

    • Java Is Easy to Learn

  • Getting Started Programming in Java

    • Getting a Java Development Environment

    • Installing the JDK and Sample Files

    • Configuring the JDK

    • Creating a Java Application

    • Creating a Java Applet

  • Troubleshooting

  • Summary

  • Q&A




Day   Object-Oriented Programming and Java

  • Thinking in Objects: An Analogy

  • Objects and Classes

  • Behavior and Attributes

    • Attributes

    • Behavior

    • Creating a Class

  • Inheritance, Interfaces, and Packages

    • Inheritance

    • Creating a Class Hierarchy

    • How Inheritance Works

    • Single and Multiple Inheritance

    • Interfaces and Packages

    • Creating a Subclass

  • Summary

  • Q&A




Day   Java Basics

  • Statements and Expressions

  • Variables and Data Types

    • Declaring Variables

    • Notes on Variable Names

    • Variable Types

    • Assigning Values to Variables

  • Comments

  • Literals

    • Number Literals

    • Boolean Literals

    • Character Literals

    • String Literals

  • Expressions and Operators

    • Arithmetic

    • More About Assignment

    • Incrementing and Decrementing

    • Comparisons

    • Logical Operators

    • Bitwise Operators

    • Operator Precedence

  • String Arithmetic

  • Summary

  • Q&A




Day   Working with Objects

  • Creating New Objects

    • Using new

    • What new Does

    • A Note on Memory Management

  • Accessing and Setting Class and Instance Variables

    • Getting Values

    • Changing Values

    • Class Variables

  • Calling Methods

    • Class Methods

  • References to Objects

  • Casting and Converting Objects and Primitive Types

    • Casting Primitive Types

    • Casting Objects

    • Converting Primitive Types to Objects and Vice Versa

  • Odds and Ends

    • Comparing Objects

    • Determining the Class of an Object

  • Class and Object Reflection (Java 1.1)

  • The Java Class Library

  • Summary

  • Q&A




Day   Arrays, Conditionals, and Loops

  • Arrays

    • Declaring Array Variables

    • Creating Array Objects

    • Accessing Array Elements

    • Changing Array Elements

    • Multidimensional Arrays

  • Block Statements

  • if Conditionals

    • The Conditional Operator

  • switch Conditionals

  • for Loops

  • while and do Loops

    • while Loops

    • do...while Loops

  • Breaking Out of Loops

    • Labeled Loops

  • Summary

  • Q&A




Day   Creating Classes and Applications in Java

  • Defining Classes

  • Creating Instance and Class Variables

    • Defining Instance Variables

    • Constants

    • Class Variables

  • Creating Methods

    • Defining Methods

    • The this Keyword

    • Variable Scope and Method Definitions

    • Passing Arguments to Methods

    • Class Methods

  • Creating Java Applications

    • Helper Classes

  • Java Applications and Command-Line Arguments

    • Passing Arguments to Java Programs

    • Handling Arguments in Your Java Program

  • Summary

  • Q&A




Day   More About Methods

  • Creating Methods with the Same Name, Different Arguments

  • Constructor Methods

    • Basic Constructors

    • Calling Another Constructor

    • Overloading Constructors

  • Overriding Methods

    • Creating Methods That Override Existing Methods

    • Calling the Original Method

    • Overriding Constructors

  • Finalizer Methods

  • Summary

  • Q&A




Day   Java Applet Basics

  • How Applets and Applications Are Different

  • Creating Applets

    • Major Applet Activities

    • A Simple Applet

  • Including an Applet on a Web Page

    • The  Tag

    • Testing the Result

    • Making Java Applets Available to the Web

    • More About the  Tag

      • ALIGN

      • HSPACE and VSPACE

      • CODE and CODEBASE

    • Java Archives

    • Passing Parameters to Applets

    • Summary

    • Q&A




      Day   Graphics, Fonts, and Color

      • The Graphics Class

        • The Graphics Coordinate System

      • Drawing and Filling

        • Lines

        • Rectangles

        • Polygons

        • Ovals

        • Arcs

        • A Simple Graphics Example

        • Copying and Clearing

      • Text and Fonts

        • Creating Font Objects

        • Drawing Characters and Strings

        • Finding Out Information About a Font

      • Color

        • Using Color Objects

        • Testing and Setting the Current Colors

        • A Simple Color Example

      • Summary

      • Q&A




      Day 10   Simple Animation and Threads

      • Creating Animation in Java

        • Painting and Repainting

        • Starting and Stopping an Applet's Execution

        • The Missing Link: Threads

        • Putting It Together

      • Threads: What They Are and Why You Need Them

        • Writing Applets with Threads

        • Another Look at the Digital Clock

      • Reducing Animation Flicker

        • Flicker and How to Avoid It

        • How to Override update()

        • Solution One: Don't Clear the Screen

        • Solution Two: Redraw Only What You Have To

      • Summary

      • Q&A




      Day 11   More Animation, Images, and Sound

      • Retrieving and Using Images

        • Getting Images

        • Drawing Images

        • A Note About Image Observers

        • Modifying Images

      • Creating Animation Using Images

        • An Example: Neko

      • Retrieving and Using Sounds

      • Using Animation Packages

        • Sun's Animator Applet

        • Dimension X's Liquid Motion

      • More About Flicker: Double-Buffering

        • Creating Applets with Double-Buffering

        • A Note on Disposing Graphics Contexts

        • An Example: Checkers Revisited

      • Summary

      • Q&A




      Day 12   Managing Simple Events and Interactivity

      • Mouse Clicks

        • Mouse Down and Mouse Up Events

        • An Example: Spots

        • Double-Clicks

      • Mouse Movements

        • Mouse Drag and Mouse Move Events

        • Mouse Enter and Mouse Exit Events

        • An Example: Drawing Lines

        • Keyboard Events

        • The keyDown() and keyUp() Methods

        • Default Keys

        • An Example: Entering, Displaying, and Moving Characters

        • Testing for Modifier Keys and Multiple Mouse Buttons

      • The awt Event Handler

      • Summary

      • Q&A




      Day 13   Creating User Interfaces with the awt

      • An awt Overview

      • The Basic User Interface Components

        • Labels

        • Buttons

        • Check Boxes

        • Radio Buttons

        • Choice Menus

        • Text Fields

      • Panels and Layout

        • Layout Managers: An Overview

        • The FlowLayout Class

        • Grid Layouts

        • Border Layouts

        • Card Layouts

        • Grid Bag Layouts

        • Insets

      • Handling UI Actions and Events

      • Nesting Panels and Components

        • Nested Panels

        • Events and Nested Panels

      • More UI Components

        • Text Areas

        • Scrolling Lists

        • Scrollbars and Sliders

        • Canvases

      • More UI Events

      • Fun with Components

      • A Complete Example: RGB-to-HSB Converter

        • Designing and Creating the Applet Layout

        • Defining the Subpanels

        • Handling the Actions

        • Updating the Result

        • The Complete Source Code

      • Up and Coming in Java 1.1

      • Summary

      • Q&A




      Day 14   Windows, Networking, and Other Tidbits

      • Windows, Menus, and Dialog Boxes

        • The awt Window Classes

        • Frames

        • Closing Windows

        • Menus

        • Dialog Boxes

        • Cursors

        • Window Events

        • Standalone awt Applications

      • Networking in Java

        • Creating Links Inside Applets

        • Opening Web Connections

        • openStream()

        • Sockets

        • Changes to Sockets for Java 1.1

      • Other Applet Hints

        • The showStatus() Method

        • Applet Information

        • Communicating Between Applets

      • Summary

      • Q&A




      Day 15   Modifiers, Access Control, and Class Design

      • Modifiers

      • Controlling Access to Methods and Variables

        • Why Access Control Is Important

        • The Four Ps of Protection

        • Method Protection and Inheritance

        • Instance Variable Protection and Accessor Methods

      • Class Variables and Methods

      • Finalizing Classes, Methods, and Variables

        • Finalizing Classes

        • Finalizing Variables

        • Finalizing Methods

      • Abstract Classes and Methods

      • Summary

      • Q&A




      Day 16   Packages and Interfaces

      • Programming in the Large and Programming in the Small

      • What Are Packages?

      • Using Packages

        • Full Package and Class Names

        • The import Command

        • Name Conflicts

        • A Note About CLASSPATH and Where Classes Are Located

      • Creating Your Own Packages

        • Pick a Package Name

        • Create the Directory Structure

        • Use package to Add Your Class to a Package

        • Packages and Class Protection

      • What Are Interfaces?

        • The Problem of Single Inheritance

        • Abstract Design and Concrete Implementation

        • Interfaces and Classes

      • Implementing and Using Interfaces

        • The implements Keyword

        • Implementing Multiple Interfaces

        • Other Uses of Interfaces

      • Creating and Extending Interfaces

        • New Interfaces

        • Methods Inside Interfaces

        • Extending Interfaces

        • An Example: Enumerating Linked Lists

      • Summary

      • Q&A




      Day 17   Exceptions

      • Exceptions, the Old and Confusing Way

      • Java Exceptions

      • Managing Exceptions

        • Exception Consistency Checking

        • Protecting Code and Catching Exceptions

        • The finally Clause

      • Declaring Methods That Might Throw Exceptions

        • The throws Clause

        • Which Exceptions Should You Throw?

        • Passing On Exceptions

        • throws and Inheritance

      • Creating and Throwing Your Own Exceptions

        • Throwing Exceptions

        • Creating Your Own Exceptions

        • Doing It All: Combining throws, try, and throw

      • When and When Not to Use Exceptions

        • When to Use Exceptions

        • When Not to Use Exceptions

        • Bad Style Using Exceptions

      • Summary

      • Q&A




      Day 18   Multithreading

      • Thread Fundamentals

      • The Problem with Parallelism

      • Thinking Multithreaded

        • Points About Points

        • Protecting a Class Variable

      • Creating and Using Threads

        • The Runnable Interface

        • ThreadTester

        • NamedThreadTester

      • Knowing When a Thread Has Stopped

      • Thread Scheduling

        • Preemptive Versus Nonpreemptive

        • Testing Your Scheduler

      • Summary

      • Q&A




      Day 19   Streams and I/O

      • What Are Streams?

      • The java.io Package

      • Input Streams

        • The Abstract Class InputStream

        • ByteArrayInputStream

        • FileInputStream

        • FilterInputStream

        • PipedInputStream

        • SequenceInputStream

        • StringBufferInputStream

      • Output Streams

        • The Abstract Class OutputStream

        • ByteArrayOutputStream

        • FileOutputStream

        • FilterOutputStream

        • PipedOutputStream

      • Related Classes

      • Object Serialization (Java 1.1)

      • Summary

      • Q&A




      Day 20   Using Native Methods and Libraries

      • Why Use Native Methods?

        • Advantages of Using Native Methods

      • Disadvantages of Native Methods

      • The Illusion of Required Efficiency

        • Design First, Efficiency Later

        • Just-in-Time Compilers

        • Simple Optimization Tricks

      • Writing Native Methods

        • Write Your Java Code

        • Generate Header and Stub Files

        • Implementing the Native Library

        • Using Your Library

      • Tools and Techniques for Writing Native Implementations

        • Names

        • Accessing Java Objects

        • Calling Methods

        • Creating New Java Objects

        • Handling Exceptions

        • Dealing with Strings

      • Summary

      • Q&A




      Day 21   Under the Hood

      • -The Big Picture

        • Why It's a Powerful Vision

      • The Java Virtual Machine

        • An Overview

        • The Fundamental Parts

        • The Constant Pool

        • Limitations

      • The Bytecode Interpreter

      • Just-in-Time Compilers

      • The Class File Format

      • Method Signatures

      • The Garbage Collector

        • The Problem

        • The Solution

        • Java's Parallel Garbage Collector

      • The Security Story

        • Why You Should Worry

        • Why You Might Not Have To

        • Java's Applet Security Model

        • Signed Applets

        • Coming Up in Java 1.1

      • Summary

      • Q&A




      Day 22   Java Programming Tools

      • Overview of the Standard JDK Tools

      • The Runtime Interpreter

        • Usage

        • The OptionsArgument

        • The Non-Optimized Interpreter

      • The Compiler

        • Usage

        • The OptionsArgument

        • The Non-Optimizing Compiler

      • The Applet Viewer

        • Usage

        • The OptionsArgument

        • Commands

        • Profiling Java Applets

      • The Debugger

        • Usage

        • The OptionsArgument

        • Commands

      • The Class File Disassembler

        • Usage

        • The OptionsArgument

      • The Header and Stub File Generator

        • Usage

        • The OptionsArgument

      • The Documentation Generator

        • Usage

        • The OptionsArgument

        • Documentation Tags

      • Visual Development Tools

        • Sun's Java WorkShop

        • Symantec Café

        • Microsoft Visual J++

        • Natural Intelligence's Roaster

        • Rogue Wave Software's JFactory

        • Penumbra Software's Mojo

        • Aimtech's Jamba

        • Kinetix's Hyperwire

      • Summary

      • Q&A




      Day 23   Working with Data Structures in Java

      • Data Structure Fundamentals

      • The Standard Java Data Structures

        • Enumerations

        • Bit Sets

        • Vectors

        • Stacks

        • Dictionaries

        • Hash Tables

      • Building Your Own Data Structures

        • Linked List Basics

        • Implementing a Linked List

      • Summary

      • Q&A




      Day 24   Advanced Animation and Media

      • What Is Animation?

      • Types of Animation

        • Frame-Based Animation

        • Cast-Based Animation

      • Tracking Images

      • The MediaTracker Class

      • Implementing Sprite Animation

        • The Sprite Class

        • The SpriteVector Class

        • The Background Classes

      • Sample Applet: Sharks

      • Summary

      • Q&A




      Day 25   Fun with Image Filters

      • The Basics of Color

      • Color Images in Java

      • Color Models

        • Direct Color Models

        • Index Color Models

      • The Color Model Classes

      • Image Filters

      • The Image Filter Classes

      • Writing Your Own Image Filters

        • A Color Image Filter

        • An Alpha Image Filter

        • A Brightness Image Filter

      • Using Image Filters

      • Summary

      • Q&A




      Day 26   Client/Server Networking in Java

      • Internet Network Basics

        • Addresses

        • Protocols

        • Ports

      • The Client/Server Paradigm

      • Sockets

        • Datagram Sockets

        • Stream Sockets

      • Fortune: A Datagram Client and Server

        • Designing Fortune

        • Implementing the Fortune Server

        • Implementing the Fortune Client Applet

        • Running Fortune

      • Trivia: A Stream Client and Server

        • Designing Trivia

        • Implementing the Trivia Server

        • Implementing the Trivia Client Applet

        • Running Trivia

      • Summary

      • Q&A




      Day 27   The Standard Extension APIs

      • Java API Overview

      • The Enterprise API

        • Java Database Connectivity

        • Interface Definition Language

        • Remote Method Invocation

      • The Commerce API

      • The Management API

      • The Server API

      • The Media API

      • The Security API

      • The Java Beans API

      • The Embedded API

      • Summary

      • Q&A




      Day 28   Emerging Technologies

      • Java Beans

        • The Goal of Java Beans

        • How Java Beans Relates to Java

        • The Java Beans API

      • JavaOS

        • Overhead

        • Industry Support

      • Java Microprocessors

        • picoJAVA

        • microJAVA

        • UltraJAVA

      • Summary

      • Q&A




      appendix   Language Summary

      • Reserved Words

      • Comments

      • Literals




      • Variable Declaration




      • Variable Assignment




      • Operators




      • Objects




      • Arrays




      • Loops and Conditionals




      • Class Definitions




      • Method and Constructor Definitions

      • Packages, Interfaces, and Importing

      • Exceptions and Guarding




      appendix   Class Hierarchy Diagrams

      • About These Diagrams

      appendix   The Java Class Library

      • java.lang

        • Interfaces




        • Classes




      • java.util

        • Interfaces




        • Classes




      • java.io

        • Interfaces




        • Classes




      • java.net

        • Interfaces




        • Classes




      • java.awt

        • Interfaces




        • Classes




      • java.awt.image

        • Interfaces




        • Classes




      • java.awt.peer

      • java.applet

        • Interfaces




        • Classes




      appendix   Bytecodes Reference

      • The _quick Bytecodes

      appendix   java.applet Package Reference

      • AppletContext

      • AppletStub

      • AudioClip

      • Applet

      appendix   java.awt Package Reference

      • LayoutManager

      • MenuContainer

      • BorderLayout

      • Button

      • Canvas

      • CardLayout

      • Checkbox

      • CheckboxGroup

      • CheckboxMenuItem

      • Choice

      • Color

      • Component

      • Container

      • Dialog

      • Dimension

      • Event

      • FileDialog

      • FlowLayout

      • Font

      • FontMetrics

      • Frame

      • Graphics

      • GridBagConstraints

      • GridBagLayout

      • GridLayout

      • Image

      • Insets

      • Label

      • List

      • MediaTracker

      • Menu

      • MenuBar

      • MenuComponent

      • MenuItem

      • Panel

      • Point

      • Polygon

      • Rectangle

      • Scrollbar

      • TextArea

      • TextComponent

      • TextField

      • Toolkit

      • Window

        • awtException

      • awtError

      appendix   java.awt.image Package Reference

      • ImageConsumer

      • ImageObserver

      • ImageProducer

      • ColorModel

      • CropImageFilter

      • DirectColorModel

      • FilteredImageSource

      • ImageFilter

      • IndexColorModel

      • MemoryImageSource

      • PixelGrabber

      • RGBImageFilter

      appendix   java.awt.peer Package Reference

      • ButtonPeer

      • CanvasPeer

      • CheckboxMenuItemPeer

      • CheckboxPeer

      • ChoicePeer

      • ComponentPeer

      • ContainerPeer

      • DialogPeer

      • FileDialogPeer

      • FramePeer

      • LabelPeer

      • ListPeer

      • addItem

      • MenuBarPeer

      • MenuComponentPeer

      • MenuItemPeer

      • MenuPeer

      • PanelPeer

      • ScrollbarPeer

      • TextAreaPeer

      • TextComponentPeer

      • TextFieldPeer

      • WindowPeer

      appendix   java.io Package Reference

      • DataInput

      • DataOutput

      • FilenameFilter

      • BufferedInputstream

      • BufferedOutputStream

      • ByteArrayInputStream

      • ByteArrayOutputStream

      • DataInputStream

      • DataOutputStream

      • File

      • FileDescriptor

      • FileInputStream

      • FileOutputStream

      • FilterInputStream

      • FilterOutputStream

      • InputStream

      • LineNumberInputStream

      • OutputStream

      • PipedInputStream

      • PipedOutputStream

      • PrintStream

      • PushbackInputStream

      • RandomAccessFile

      • SequenceInputStream

      • StreamTokenizer

      • StringBufferInputStream

      • EOFException

      • FileNotFoundException

      • IOException

      • InterruptedIOException

      • UTFDataFormatException

      appendix   java.lang Package Reference

      • Cloneable

      • Runnable

      • Boolean

      • Character

      • Class

      • ClassLoader

      • Compiler

      • Double

      • Float

      • Integer

      • Long

      • Math

      • Number

      • Object

      • Process

      • Runtime

      • SecurityManager

      • String

      • StringBuffer

      • System

      • Thread

      • ThreadGroup

      • Throwable

      • RuntimeException

      • ClassNotFoundException

      • CloneNotSupportedException

      • Exception

      • IllegalAccessException

      • IllegalArgumentException

      • IllegalMonitorStateException

      • IllegalThreadStateException

      • IndexOutOfBoundsException

      • InstantiationException

      • InterruptedException

      • NegativeArraySizeException

      • NullPointerException

      • NumberFormatException

      • RuntimeException

      • SecurityException

      • StringIndexOutOfBoundsException

      • AbstractMethodError

      • ClassFormatError

      • Error

      • IllegalAccessError

      • IncompatibleClassChangeError

      • InstantiationError

      • InternalError

      • LinkageError

      • NoClassDefFoundError

      • NoSuchFieldError

      • NoSuchMethodError

      • OutOfMemoryError

      • StackOverflowError

      • ThreadDeath

      • UnknownError

      • UnsatisfiedLinkError

      • VerifyError

      • VirtualMachineError

      appendix   java.net Package Reference

      • ContentHandlerFactory

      • SocketImplFactory

      • URLStreamHandlerFactory

      • ContentHandler

      • DatagramPacket

      • DatagramSocket

      • InetAddress

      • ServerSocket

      • Socket

      • SocketImpl

      • URL

      • URLConnection

      • URLEncoder

      • MalformedURLException

      • ProtocolException

      • SocketException

      • UnknownHostException

      • UnknownServiceException

      appendix   java.util Package Reference

      • Enumeration

      • Observer

      • BitSet

      • Date

      • Dictionary

      • Hashtable

      • Observable

      • Properties

      • Random

      • Stack

      • StringTokenizer

      • Vector

      • EmptyStackException

      • NoSuchElementException

      Credits

      Copyright © 1996 by Sams.net Publishing

      All rights reserved. No part of this book shall be reproduced, stored in a retrieval system, or transmitted by any means, electronic, mechanical, photocopying, recording, or otherwise, without written permission from the publisher. No patent liability is assumed with respect to the use of the information contained herein. Although every precaution has been taken in the preparation of this book, the publisher and author assume no responsibility for errors or omissions. Neither is any liability assumed for damages resulting from the use of the information contained herein. For information, address Sams.net Publishing, 201 W. 103rd St., Indianapolis, IN 46290.



    • Download 9.83 Mb.

      Share with your friends:
  1   2   3




The database is protected by copyright ©ininet.org 2024
send message

    Main page