logo资料库

Core Java Volume I--Fundamental (11th Edition).pdf

第1页 / 共2413页
第2页 / 共2413页
第3页 / 共2413页
第4页 / 共2413页
第5页 / 共2413页
第6页 / 共2413页
第7页 / 共2413页
第8页 / 共2413页
资料共2413页,剩余部分请下载后查看
About This E-Book
Title Page
Copyright Page
Contents
Preface
Acknowledgments
Chapter 1: An Introduction to Java
1.1 Java as a Programming Platform
1.2 The Java “White Paper” Buzzwords
1.3 Java Applets and the Internet
1.4 A Short History of Java
1.5 Common Misconceptions about Java
Chapter 2: The Java Programming Environment
2.1 Installing the Java Development Kit
2.2 Using the Command-Line Tools
2.3 Using an Integrated Development Environment
2.4 JShell
Chapter 3: Fundamental Programming Structures in Java
3.1 A Simple Java Program
3.2 Comments
3.3 Data Types
3.4 Variables and Constants
3.5 Operators
3.6 Strings
3.7 Input and Output
3.8 Control Flow
3.9 Big Numbers
3.10 Arrays
Chapter 4: Objects and Classes
4.1 Introduction to Object-Oriented Programming
4.2 Using Predefined Classes
4.3 Defining Your Own Classes
4.4 Static Fields and Methods
4.5 Method Parameters
4.6 Object Construction
4.7 Packages
4.8 JAR Files
4.9 Documentation Comments
4.10 Class Design Hints
Chapter 5: Inheritance
5.1 Classes, Superclasses, and Subclasses
5.2 Object: The Cosmic Superclass
5.3 Generic Array Lists
5.4 Object Wrappers and Autoboxing
5.5 Methods with a Variable Number of Parameters
5.6 Enumeration Classes
5.7 Reflection
5.8 Design Hints for Inheritance
Chapter 6: Interfaces, Lambda Expressions, and Inner Classes
6.1 Interfaces
6.2 Lambda Expressions
6.3 Inner Classes
6.4 Service Loaders
6.5 Proxies
Chapter 7: Exceptions, Assertions, and Logging
7.1 Dealing with Errors
7.2 Catching Exceptions
7.3 Tips for Using Exceptions
7.4 Using Assertions
7.5 Logging
7.6 Debugging Tips
Chapter 8: Generic Programming
8.1 Why Generic Programming?
8.2 Defining a Simple Generic Class
8.3 Generic Methods
8.4 Bounds for Type Variables
8.5 Generic Code and the Virtual Machine
8.6 Restrictions and Limitations
8.7 Inheritance Rules for Generic Types
8.8 Wildcard Types
8.9 Reflection and Generics
Chapter 9: Collections
9.1 The Java Collections Framework
9.2 Interfaces in the Collections Framework
9.3 Concrete Collections
9.4 Maps
9.5 Views and Wrappers
9.6 Algorithms
9.7 Legacy Collections
Chapter 10: Graphical User Interface Programming
10.1 A History of Java User Interface Toolkits
10.2 Displaying Frames
10.3 Displaying Information in a Component
10.4 Event Handling
10.5 The Preferences API
Chapter 11: User Interface Components with Swing
11.1 Swing and the Model-View-Controller Design Pattern
11.2 Introduction to Layout Management
11.3 Text Input
11.4 Choice Components
11.5 Menus
11.6 Sophisticated Layout Management
11.7 Dialog Boxes
Chapter 12: Concurrency
12.1 What Are Threads?
12.2 Thread States
12.3 Thread Properties
12.4 Synchronization
12.5 Thread-Safe Collections
12.6 Tasks and Thread Pools
12.7 Asynchronous Computations
12.8 Processes
Appendix
Index
Credits
Code Snippets
About This E-Book EPUB is an open, industry-standard format for e-books. However, support for EPUB and its many features varies across reading devices and applications. Use your device or app settings to customize the presentation to your liking. Settings that you can customize often include font, font size, single or double column, landscape or portrait mode, and figures that you can click or tap to enlarge. For additional information about the settings and features on your reading device or app, visit the device manufacturer’s Web site. Many titles include programming code or configuration examples. To optimize the presentation of these elements, view the e-book in single-column, landscape mode and adjust the font size to the smallest setting. In addition to presenting code and configurations in the reflowable text format, we have included images of the code that mimic the presentation found in the print book; therefore, where the reflowable format may compromise the presentation of the code listing, you will see a “Click here to view code image” link. Click the link to view the print- fidelity code image. To return to the previous page viewed, click the Back button on your device or app.
Core Java Volume I–Fundamentals Eleventh Edition Cay S. Horstmann Boston • Columbus • New York • San Francisco • Amsterdam • Cape Town Dubai • London • Madrid • Milan • Munich • Paris • Montreal • Toronto • Delhi • Mexico City São Paulo • Sydney • Hong Kong • Seoul • Singapore • Taipei • Tokyo
The author and publisher have taken care in the preparation of this book, but make no expressed or implied warranty of any kind and assume no responsibility for errors or omissions. No liability is assumed for incidental or consequential damages in connection with or arising out of the use of the information or programs contained herein. For information about buying this title in bulk quantities, or for special sales opportunities (which may include electronic versions; custom cover designs; and content particular to your business, training goals, marketing focus, or branding interests), please contact our corporate sales department at corpsales@pearsoned.com or (800) 382-3419. For government sales inquiries, please contact governmentsales@pearsoned.com. For questions about sales outside the United States, please contact international@pearsoned.com. Visit us on the Web: informit.com Library of Congress Preassigned Control Number: 2018942070 Copyright © 2019 Pearson Education Inc. Portions copyright © 1996-2013 Oracle and/or its affiliates. All Rights Reserved. Oracle America Inc. does not make any representations or warranties as to the accuracy, adequacy or completeness of any information contained in this work, and is not responsible for any errors or omissions. Microsoft and/or its respective suppliers make no representations about the suitability of the information contained in the documents and related graphics published as part of the services for any purpose. All such documents and related graphics are provided "as is" without warranty of any kind. Microsoft and/or its respective suppliers hereby disclaim all warranties and conditions with regard to this information, including all warranties and conditions of merchantability, whether express, implied or statutory, fitness for a particular purpose, title and non-infringement. In no event shall Microsoft and/or its respective suppliers be liable for any special, indirect or consequential damages or any damages whatsoever resulting from loss of use, data or profits, whether in an action of contract, negligence or other tortious action, arising out of or in connection with the use or performance of information available from the services. The documents and related graphics contained herein could include technical inaccuracies or typographical errors. Changes are periodically added to the information herein. Microsoft and/or its respective suppliers may make improvements and/or changes in the product(s) and/or the program(s) described herein at any time. Partial screen shots may be viewed in full within the software version specified. Microsoft® Windows®, and Microsoft Office® are registered trademarks of the Microsoft Corporation in the U.S.A. and other countries. This book is not sponsored or endorsed by or affiliated with the Microsoft Corporation. All rights reserved. This publication is protected by copyright, and permission must be obtained from the publisher prior to any prohibited reproduction, storage in a retrieval system, or transmission in any form or by any means, electronic, mechanical, photocopying, recording, or likewise. For information regarding permissions, request forms and the appropriate contacts within the Pearson Education Global Rights & Permissions Department, please visit www.pearsoned.com/permissions/. ISBN-13: 978-0-13-516630-7 ISBN-10: 0-13-516630-6 1 18
Contents Preface Acknowledgments Chapter 1: An Introduction to Java 1.1 Java as a Programming Platform 1.2 The Java “White Paper” Buzzwords 1.2.1 Simple 1.2.2 Object-Oriented 1.2.3 Distributed 1.2.4 Robust 1.2.5 Secure 1.2.6 Architecture-Neutral 1.2.7 Portable 1.2.8 Interpreted 1.2.9 High-Performance 1.2.10 Multithreaded 1.2.11 Dynamic 1.3 Java Applets and the Internet 1.4 A Short History of Java 1.5 Common Misconceptions about Java Chapter 2: The Java Programming Environment 2.1 Installing the Java Development Kit 2.1.1 Downloading the JDK 2.1.2 Setting up the JDK 2.1.3 Installing Source Files and Documentation 2.2 Using the Command-Line Tools 2.3 Using an Integrated Development Environment 2.4 JShell Chapter 3: Fundamental Programming Structures in Java 3.1 A Simple Java Program 3.2 Comments 3.3 Data Types 3.3.1 Integer Types 3.3.2 Floating-Point Types
3.3.3 The char Type 3.3.4 Unicode and the char Type 3.3.5 The boolean Type 3.4 Variables and Constants 3.4.1 Declaring Variables 3.4.2 Initializing Variables 3.4.3 Constants 3.4.4 Enumerated Types 3.5 Operators 3.5.1 Arithmetic Operators 3.5.2 Mathematical Functions and Constants 3.5.3 Conversions between Numeric Types 3.5.4 Casts 3.5.5 Combining Assignment with Operators 3.5.6 Increment and Decrement Operators 3.5.7 Relational and boolean Operators 3.5.8 Bitwise Operators 3.5.9 Parentheses and Operator Hierarchy 3.6 Strings 3.6.1 Substrings 3.6.2 Concatenation 3.6.3 Strings Are Immutable 3.6.4 Testing Strings for Equality 3.6.5 Empty and Null Strings 3.6.6 Code Points and Code Units 3.6.7 The String API 3.6.8 Reading the Online API Documentation 3.6.9 Building Strings 3.7 Input and Output 3.7.1 Reading Input 3.7.2 Formatting Output 3.7.3 File Input and Output 3.8 Control Flow 3.8.1 Block Scope 3.8.2 Conditional Statements 3.8.3 Loops 3.8.4 Determinate Loops 3.8.5 Multiple Selections—The switch Statement
3.8.6 Statements That Break Control Flow 3.9 Big Numbers 3.10 Arrays 3.10.1 Declaring Arrays 3.10.2 Accessing Array Elements 3.10.3 The “for each” Loop 3.10.4 Array Copying 3.10.5 Command-Line Parameters 3.10.6 Array Sorting 3.10.7 Multidimensional Arrays 3.10.8 Ragged Arrays Chapter 4: Objects and Classes 4.1 Introduction to Object-Oriented Programming 4.1.1 Classes 4.1.2 Objects 4.1.3 Identifying Classes 4.1.4 Relationships between Classes 4.2 Using Predefined Classes 4.2.1 Objects and Object Variables 4.2.2 The LocalDate Class of the Java Library 4.2.3 Mutator and Accessor Methods 4.3 Defining Your Own Classes 4.3.1 An Employee Class 4.3.2 Use of Multiple Source Files 4.3.3 Dissecting the Employee Class 4.3.4 First Steps with Constructors 4.3.5 Declaring Local Variables with var 4.3.6 Working with null References 4.3.7 Implicit and Explicit Parameters 4.3.8 Benefits of Encapsulation 4.3.9 Class-Based Access Privileges 4.3.10 Private Methods 4.3.11 Final Instance Fields 4.4 Static Fields and Methods 4.4.1 Static Fields 4.4.2 Static Constants 4.4.3 Static Methods 4.4.4 Factory Methods
4.4.5 The main Method 4.5 Method Parameters 4.6 Object Construction 4.6.1 Overloading 4.6.2 Default Field Initialization 4.6.3 The Constructor with No Arguments 4.6.4 Explicit Field Initialization 4.6.5 Parameter Names 4.6.6 Calling Another Constructor 4.6.7 Initialization Blocks 4.6.8 Object Destruction and the finalize Method 4.7 Packages 4.7.1 Package Names 4.7.2 Class Importation 4.7.3 Static Imports 4.7.4 Addition of a Class into a Package 4.7.5 Package Access 4.7.6 The Class Path 4.7.7 Setting the Class Path 4.8 JAR Files 4.8.1 Creating JAR files 4.8.2 The Manifest 4.8.3 Executable JAR Files 4.8.4 Multi-Release JAR Files 4.8.5 A Note about Command-Line Options 4.9 Documentation Comments 4.9.1 Comment Insertion 4.9.2 Class Comments 4.9.3 Method Comments 4.9.4 Field Comments 4.9.5 General Comments 4.9.6 Package Comments 4.9.7 Comment Extraction 4.10 Class Design Hints Chapter 5: Inheritance 5.1 Classes, Superclasses, and Subclasses 5.1.1 Defining Subclasses 5.1.2 Overriding Methods
分享到:
收藏