[PDF] [PDF] Java Programming Language, Java SE 6 - miageprojet2

Oracle and Java are registered trademarks of Oracle and/or its affiliates Other names may Palatino italics is used for book titles, new words or terms, or words  



Previous PDF Next PDF





[PDF] Java Programming Language

Sun, Sun Microsystems, the Sun Logo, Solstice, Java, JavaBeans, JDK, and Solaris are trademarks or Palatino italics – Book titles, new words or terms, and



[PDF] The Java™ Language Specification - Oracle Help Center

21 jan 1996 · Sun, Sun Microsystems, the Sun logo, Solaris, Java, JavaScript, JDK, and In their book The C Programming Language, Brian Kernighan and 



[PDF] Sun Educational Services - SL-285 Java Programming Language

Sun, Sun Microsystems, the Sun Logo, Solaris, OpenWindows, Java, JavaSoft, and Palatino italics is used for book titles, new words or terms, or words that are 



[PDF] Java Programming Language, Java SE 6 - miageprojet2

Oracle and Java are registered trademarks of Oracle and/or its affiliates Other names may Palatino italics is used for book titles, new words or terms, or words  



[PDF] Java (programming language) - instructional media + magic

Sun Microsystems released the first public implementation as Java 1 0 in "The Java Language Specification, 2nd Edition" (http://java sun com/docs/books/jls/



[PDF] The Java Language Environment

Sun, the Sun logo, Sun Microsystems, Solaris, HotJava, and Java are trademarks a long line of illustrious programming books by showing you the HelloWorld



[PDF] Teach Yourself Java in 21 Days - Carnegie Mellon School of

This book is intended for people with at least some basic programming back- The Java language was developed at Sun Microsystems in 1991 as part of a 



[PDF] Java graphics programming books pdf - Squarespace

(Viewed 4316 times) Java Swing Tutorial by Jan Bodnar - ZetCode , 2011Swing library Official Java GUI tool released by sun microsystems Graphics with Java 

[PDF] sun yat sen university coronavirus temperature

[PDF] sunamerica life insurance company phone number

[PDF] sunbury municipal court

[PDF] sunlife alberta

[PDF] sunlife claim forms

[PDF] sunlife insurance

[PDF] sunlife shares login

[PDF] sunlife.co.uk email address

[PDF] super dinner meal kfc calories

[PDF] super fund abn

[PDF] super scientist trimpe 2002

[PDF] super simplified individual 401(k profit sharing plan)

[PDF] super u 14 rue paul bert 75011 paris

[PDF] superannuation fund number

[PDF] superficie france métropole

This page intentionally left blank

Java™ Programming LanguageivCopyright 2008 Sun Microsystems, Inc. All Rights Reserved. Sun Services, Revision G.2

Course Contents

About This Course ........................................................................ ............. Preface-xvi Course Goals ........................................................................ Course Overview ........................................................................ Course Map ........................................................................ Topics Not Covered ........................................................................ How Prepared Are You? ........................................................................ Introductions ........................................................................ How to Use the Icons ........................................................................

Typographical Conventions and Symbols ........................................................................

...Preface-xxv Getting Started ........................................................................ ................................. 1-1 Objectives ........................................................................ Relevance ........................................................................

What Is the Javaª Technology? ........................................................................

...................................1-4

Primary Goals of the Java Technology ........................................................................

........................1-5 The Java Virtual Machine ........................................................................ Garbage Collection ........................................................................

The Java Runtime Environment ........................................................................

..................................1-12

Operation of the JRE With a Just-In-Time (JIT) Compiler ..............................................................1-13

JVMª Tasks ........................................................................ The Class Loader ........................................................................ The Bytecode Verifier ........................................................................ A Simple Java Application ........................................................................ TheTestGreeting Application ........................................................................ .................................1-18 TheGreeting Class ........................................................................

Compiling and Running theTestGreeting Program ....................................................................1-20

Sun Educational Services

Java™ Programming LanguagevCopyright 2008 Sun Microsystems, Inc. All Rights Reserved. Sun Services, Revision G.2

Compile-Time Errors ........................................................................ Runtime Errors ........................................................................

Java Technology Runtime Environment ........................................................................

...................1-23 Object-Oriented Programming ........................................................................ ........ 2-1 Objectives ........................................................................ Relevance ........................................................................ Software Engineering ........................................................................

The Analysis and Design Phase ........................................................................

....................................2-5 Abstraction ........................................................................

Classes as Blueprints for Objects ........................................................................

..................................2-7

Declaring Java Technology Classes ........................................................................

..............................2-8 Declaring Attributes ........................................................................ Declaring Methods ........................................................................ Accessing Object Members ........................................................................ Information Hiding ........................................................................ Encapsulation ........................................................................ Declaring Constructors ........................................................................ The Default Constructor ........................................................................ Source File Layout ........................................................................ Software Packages ........................................................................ Thepackage Statement ........................................................................ Theimport Statement ........................................................................

Directory Layout and Packages ........................................................................

..................................2-21 Development ........................................................................

Compiling Using the-d Option ........................................................................

.................................2-23 Terminology Recap ........................................................................

Using the Java Technology API Documentation ........................................................................

......2-25

Java Technology API Documentation ........................................................................

.......................2-26

Sun Educational Services

Java™ Programming LanguageviCopyright 2008 Sun Microsystems, Inc. All Rights Reserved. Sun Services, Revision G.2

Identifiers, Keywords, and Types ........................................................................

... 3-1 Objectives ........................................................................ Relevance ........................................................................ Comments ........................................................................

Semicolons, Blocks, and White Space ........................................................................

..........................3-6 Identifiers ........................................................................

Java Programming Language Keywords ........................................................................

..................3-10 Primitive Types ........................................................................ Logical Ðboolean........................................................................ Textual Ðchar........................................................................ Textual ÐString........................................................................

Integral Ðbyte,short,int, andlong........................................................................

.......................3-15

Floating Point Ðfloat anddouble........................................................................

............................3-17

Variables, Declarations, and Assignments ........................................................................

................3-19 Java Reference Types ........................................................................

Constructing and Initializing Objects ........................................................................

........................3-21

Memory Allocation and Layout ........................................................................

..................................3-22

Explicit Attribute Initialization ........................................................................

...................................3-23 Executing the Constructor ........................................................................ Assigning a Variable ........................................................................ Assigning References ........................................................................ Pass-by-Value ........................................................................ Thethis Reference ........................................................................

Java Programming Language Coding Conventions ........................................................................

3-36

Expressions and Flow Control ........................................................................

....... 4-1 Objectives ........................................................................ Relevance ........................................................................ Variables and Scope ........................................................................ Variable Scope Example ........................................................................

Sun Educational Services

Java™ Programming LanguageviiCopyright 2008 Sun Microsystems, Inc. All Rights Reserved. Sun Services, Revision G.2

Variable Initialization ........................................................................

Initialization Before Use Principle ........................................................................

................................4-8 Operator Precedence ........................................................................ Logical Operators ........................................................................ Bitwise Logical Operators ........................................................................

Right-Shift Operators>> and>>>........................................................................

...............................4-12 Left-Shift Operator<<........................................................................ Shift Operator Examples ........................................................................ String Concatenation With+........................................................................ Casting ........................................................................

Promotion and Casting of Expressions ........................................................................

......................4-17 Simpleif, else Statements ........................................................................ Complexif, else Statements ........................................................................ ..................................4-19 Switch Statements ........................................................................ Looping Statements ........................................................................ Special Loop Flow Control ........................................................................ Thebreak Statement ........................................................................ Thecontinue Statement ........................................................................

Usingbreak Statements with Labels ........................................................................

.........................4-30

Usingcontinue Statements with Labels ........................................................................

..................4-31 Arrays ........................................................................ ................................................ 5-1 Objectives ........................................................................ Relevance ........................................................................ Declaring Arrays ........................................................................ Creating Arrays ........................................................................ Creating Reference Arrays ........................................................................ Initializing Arrays ........................................................................ Multidimensional Arrays ........................................................................ Array Bounds ........................................................................

Sun Educational Services

Java™ Programming LanguageviiiCopyright 2008 Sun Microsystems, Inc. All Rights Reserved. Sun Services, Revision G.2

Using the Enhancedfor Loop ........................................................................ ....................................5-13 Array Resizing ........................................................................ Copying Arrays ........................................................................ Class Design ........................................................................ ..................................... 6-1 Objectives ........................................................................ Relevance ........................................................................ Subclassing ........................................................................ Single Inheritance ........................................................................ Access Control ........................................................................ Overriding Methods ........................................................................

Overridden Methods Cannot Be Less Accessible ........................................................................

.....6-12 Invoking Overridden Methods ........................................................................ ...................................6-13 Polymorphism ........................................................................ Virtual Method Invocation ........................................................................ Heterogeneous Collections ........................................................................ Polymorphic Arguments ........................................................................ Theinstanceof Operator ........................................................................ Casting Objects ........................................................................ Overloading Methods ........................................................................

Methods Using Variable Arguments ........................................................................

.........................6-24 Overloading Constructors ........................................................................

Constructors Are Not Inherited ........................................................................

..................................6-27

Invoking Parent Class Constructors ........................................................................

...........................6-28

Constructing and Initializing Objects: A Slight Reprise ..................................................................6-30

Constructor and Initialization Examples ........................................................................

...................6-31 TheObject Class ........................................................................ Theequals Method ........................................................................ Anequals Example ........................................................................ ThetoString Method ........................................................................

Sun Educational Services

Java™ Programming LanguageixCopyright 2008 Sun Microsystems, Inc. All Rights Reserved. Sun Services, Revision G.2

Wrapper Classes ........................................................................

Autoboxing of Primitive Types ........................................................................

...................................6-43 Advanced Class Features ........................................................................ ............... 7-1 Objectives ........................................................................ Relevance ........................................................................ Thestatic Keyword ........................................................................ Class Attributes ........................................................................ Class Methods ........................................................................ Static Initializers ........................................................................ Thefinal Keyword ........................................................................ Final Variables ........................................................................ Blank Final Variables ........................................................................

Old-Style Enumerated Type Idiom ........................................................................

............................7-15 The New Enumerated Type ........................................................................ Advanced Enumerated Types ........................................................................ Static Imports ........................................................................ Abstract Classes ........................................................................ The Solution ........................................................................ Interfaces ........................................................................ The Flyer Example ........................................................................ Multiple Interface Example ........................................................................ Uses of Interfaces ........................................................................ Exceptions and Assertions ........................................................................ ............. 8-1 Objectives ........................................................................ Relevance ........................................................................ Exceptions and Assertions ........................................................................ Exceptions ........................................................................ Exception Example ........................................................................

Sun Educational Services

Java™ Programming LanguagexCopyright 2008 Sun Microsystems, Inc. All Rights Reserved. Sun Services, Revision G.2

Thetry-catch Statement ........................................................................ Call Stack Mechanism ........................................................................ Thefinally Clause ........................................................................ Exception Categories ........................................................................ Common Exceptions ........................................................................ The Handle or Declare Rule ........................................................................

Method Overriding and Exceptions ........................................................................

...........................8-15

Creating Your Own Exceptions ........................................................................

..................................8-17

Handling a User-Defined Exception ........................................................................

..........................8-18 Assertions ........................................................................

Recommended Uses of Assertions ........................................................................

.............................8-21 Internal Invariants ........................................................................ Control Flow Invariants ........................................................................

Postconditions and Class Invariants ........................................................................

..........................8-24

Controlling Runtime Evaluation of Assertions ........................................................................

........8-25

Collections and Generics Framework .................................................................... 9-1

Objectives ........................................................................ The Collections API ........................................................................ AList Example ........................................................................ TheMap Interface ........................................................................ TheMap Interface API ........................................................................ AMap Example ........................................................................ Legacy Collection Classes ........................................................................ Ordering Collections ........................................................................ TheComparable Interface ........................................................................

Example of theComparable Interface ........................................................................

.......................9-16 TheComparator Interface ........................................................................

Example of theComparator Interface ........................................................................

.......................9-21 Generics ........................................................................

Sun Educational Services

Java™ Programming LanguagexiCopyright 2008 Sun Microsystems, Inc. All Rights Reserved. Sun Services, Revision G.2

GenericSet Example ........................................................................ Generic Map Example ........................................................................

Generics: Examining Type Parameters ........................................................................

......................9-29 Wild Card Type Parameters ........................................................................ The Type-Safety Guarantee ........................................................................ The Invariance Challenge ........................................................................ The Covariance Response ........................................................................

Generics: Refactoring Existing Non-Generic Code ........................................................................

..9-35 Iterators ........................................................................ Generic Iterator Interfaces ........................................................................ The Enhancedfor Loop ........................................................................ I/O Fundamentals ........................................................................ ........................... 10-1 Objectives ........................................................................ Command-Line Arguments ........................................................................ System Properties ........................................................................ TheProperties Class ........................................................................ I/O Stream Fundamentals ........................................................................ Fundamental Stream Classes ........................................................................ Data Within Streams ........................................................................ TheInputStream Methods ........................................................................ TheOutputStream Methods ........................................................................ TheReader Methods ........................................................................ TheWriter Methods ........................................................................ Node Streams ........................................................................ A Simple Example ........................................................................ Buffered Streams ........................................................................ I/O Stream Chaining ........................................................................ Processing Streams ........................................................................

TheInputStream Class Hierarchy ........................................................................

..........................10-24

Sun Educational Services

Java™ Programming LanguagexiiCopyright 2008 Sun Microsystems, Inc. All Rights Reserved. Sun Services, Revision G.2

TheOutputStream Class Hierarchy ........................................................................

........................10-25

TheObjectInputStream and TheObjectOutputStream Classes ............................................10-26

TheSerializeDate Class ........................................................................ TheDeSerializeDate Class ........................................................................ TheReader Class Hierarchy ........................................................................ TheWriter Class Hierarchy ........................................................................ Console I/O and File I/O ........................................................................ ................. 11-1 Objectives ........................................................................ Console I/O ........................................................................ Writing to Standard Output ........................................................................ Reading From Standard Input ........................................................................ ....................................11-5 Simple Formatted Output ........................................................................ Simple Formatted Input ........................................................................ Files and File I/O ........................................................................ Creating a NewFile Object ........................................................................ TheFile Tests and Utilities ........................................................................ File Stream I/O ........................................................................ File Input Example ........................................................................ Printing a File ........................................................................ File Output Example ........................................................................

Building Java GUIs Using the Swing API ............................................................ 12-1

Objectives ........................................................................

What Are the Java Foundation Classes (JFC)? ........................................................................

..........12-3 What Is Swing? ........................................................................ Swing Architecture ........................................................................ Swing Packages ........................................................................

Examining the Composition of a Java Technology GUI .................................................................12-7

Swing Containers ........................................................................

Sun Educational Services

Java™ Programming LanguagexiiiCopyright 2008 Sun Microsystems, Inc. All Rights Reserved. Sun Services, Revision G.2

Top-Level Containers ........................................................................ Swing Components ........................................................................ Swing Component Hierarchy ........................................................................ ...................................12-12 Text Components ........................................................................ Swing Component Properties ........................................................................ ...................................12-14 Common Component Properties ........................................................................ ..............................12-15

Component-Specific Properties ........................................................................

................................12-16 Layout Managers ........................................................................ TheBorderLayoutManager ........................................................................ ...................................12-18

BorderLayout

Example ........................................................................ TheFlowLayoutManager ........................................................................

FlowLayout

Example ........................................................................ TheBoxLayout Manager ........................................................................ TheCardLayout Manager ........................................................................

GridLayout

Example ........................................................................ TheGridBagLayout Manager ........................................................................ ..................................12-29 GUI Construction ........................................................................ Programmatic Construction ........................................................................ Key Methods ........................................................................

Handling GUI-Generated Events ........................................................................

... 13-1 Objectives ........................................................................ What Is an Event? ........................................................................ Delegation Model ........................................................................ A Listener Example ........................................................................ Event Categories ........................................................................

Method Categories and Interfaces ........................................................................

..............................13-9 Complex Example ........................................................................ Multiple Listeners ........................................................................ Event Adapters ........................................................................

Sun Educational Services

Java™ Programming LanguagexivCopyright 2008 Sun Microsystems, Inc. All Rights Reserved. Sun Services, Revision G.2

Event Handling Using Inner Classes ........................................................................

.......................13-19

Event Handling Using Anonymous Classes ........................................................................

...........13-21 GUI-Based Applications ........................................................................ ................ 14-1 Objectives ........................................................................ Relevance ........................................................................ How to Create a Menu ........................................................................ Creating aJMenuBar........................................................................ Creating aJMenu........................................................................ Creating aJMenuItem........................................................................ Creating aJCheckBoxMenuItem........................................................................ ...............................14-10 Controlling Visual Aspects ........................................................................ Threads ........................................................................ ........................................... 15-1 Objectives ........................................................................ Relevance ........................................................................ Threads ........................................................................ Creating the Thread ........................................................................ Starting the Thread ........................................................................ Thread Scheduling ........................................................................ Thread Scheduling Example ........................................................................ Terminating a Thread ........................................................................ Basic Control of Threads ........................................................................ Thejoin Method ........................................................................

Other Ways to Create Threads ........................................................................

..................................15-14

Selecting a Way to Create Threads ........................................................................

...........................15-15

Using thesynchronized Keyword ........................................................................

.........................15-16 The Object Lock Flag ........................................................................ Releasing the Lock Flag ........................................................................quotesdbs_dbs20.pdfusesText_26