This revised edition of the classic "Core Java(TM), Volume I-Fundamentals," is the definitive guide to Java for serious programmers who want to put Java to work on real projects. Fully updated for the new Java SE 6 platform, this no-nonsense tutorial and reliable reference illuminates the most impor
Core Java, Volume 1: Fundamentals
โ Scribed by Horstmann, Cay S;Cornell, Gary
- Publisher
- Prentice Hall PTR; Prentice Hall/Sun Microsystems Press
- Year
- 2007;2008
- Tongue
- English
- Leaves
- 865
- Series
- Sun Microsystems Press Java series
- Edition
- 8th ed
- Category
- Library
No coin nor oath required. For personal study only.
โฆ Synopsis
This revised edition of the classic "Core Java(TM), Volume I-Fundamentals," is the definitive guide to Java for serious programmers who want to put Java to work on real projects. Fully updated for the new Java SE 6 platform, this no-nonsense tutorial and reliable reference illuminates the most important language and library features with thoroughly tested real-world examples. The example programs have been carefully crafted to be easy to understand as well as useful in practice, so you can rely on them as an outstanding starting point for your own code. Volume I is designed to quickly bring you up to speed on what's new in Java SE 6 and to help you make the transition as efficiently as possible, whether you're upgrading from an earlier version of Java or migrating from another language. The authors concentrate on the fundamental concepts of the Java language, along with the basics of user-interface programming. You'll find detailed, insightful coverage of
Java fundamentals
Object-oriented programming
Interfaces and inner classes
Reflection and proxies
The event listener model
GUI programming with Swing
Packaging applications
Exception handling
Logging and debugging
Generic programming
The collections framework
Concurrency
For detailed coverage of XML processing, networking, databases, internationalization, security, advanced AWT/Swing, and other advanced features, look for the forthcoming eighth edition of "Core Java(TM), Volume II--Advanced Features "(ISBN: 978-0-13-235479-0).
โฆ Table of Contents
Cover......Page 1
Contents......Page 6
Preface......Page 20
Acknowledgments......Page 26
1 AN INTRODUCTION TO JAVA......Page 28
The Java โWhite Paperโ Buzzwords......Page 29
Object Oriented......Page 30
Robust......Page 31
Architecture Neutral......Page 32
High Performance......Page 33
Java Applets and the Internet......Page 34
A Short History of Java......Page 36
Common Misconceptions about Java......Page 38
2 THE JAVA PROGRAMMING ENVIRONMENT......Page 42
Downloading the JDK......Page 43
Setting the Execution Path......Page 45
Installing the Core Java Program Examples......Page 47
Choosing a Development Environment......Page 48
Using the Command-Line Tools......Page 49
Troubleshooting Hints......Page 51
Using an Integrated Development Environment......Page 52
Locating Compilation Errors......Page 54
Running a Graphical Application......Page 55
Building and Running Applets......Page 58
3 FUNDAMENTAL PROGRAMMING STRUCTURES IN JAVA......Page 62
A Simple Java Program......Page 63
Comments......Page 66
Integer Types......Page 67
Floating-Point Types......Page 68
The char Type......Page 69
Variables......Page 71
Initializing Variables......Page 72
Operators......Page 73
Increment and Decrement Operators......Page 74
Relational and boolean Operators......Page 75
Mathematical Functions and Constants......Page 76
Casts......Page 78
Parentheses and Operator Hierarchy......Page 79
Strings......Page 80
Strings Are Immutable......Page 81
Code Points and Code Units......Page 83
The String API......Page 84
Reading the On-Line API Documentation......Page 86
Building Strings......Page 89
Reading Input......Page 90
Formatting Output......Page 92
File Input and Output......Page 96
Block Scope......Page 98
Conditional Statements......Page 99
Loops......Page 103
Determinate Loops......Page 107
Multiple SelectionsโThe switch Statement......Page 111
Statements That Break Control Flow......Page 113
Big Numbers......Page 115
Arrays......Page 117
The โfor eachโ Loop......Page 118
Array Initializers and Anonymous Arrays......Page 119
Array Copying......Page 120
Array Sorting......Page 122
Multidimensional Arrays......Page 126
Ragged Arrays......Page 129
4 OBJECTS AND CLASSES......Page 132
Introduction to Object-Oriented Programming......Page 133
Classes......Page 134
Identifying Classes......Page 135
Relationships between Classes......Page 136
Objects and Object Variables......Page 138
The GregorianCalendar Class of the Java Library......Page 141
Mutator and Accessor Methods......Page 142
An Employee Class......Page 149
Dissecting the Employee Class......Page 152
First Steps with Constructors......Page 153
Implicit and Explicit Parameters......Page 154
Benefits of Encapsulation......Page 156
Class-Based Access Privileges......Page 158
Static Fields......Page 159
Static Constants......Page 160
Static Methods......Page 161
The main Method......Page 162
Method Parameters......Page 165
Overloading......Page 171
Default Constructors......Page 172
Explicit Field Initialization......Page 173
Parameter Names......Page 174
Initialization Blocks......Page 175
Object Destruction and the finalize Method......Page 179
Class Importation......Page 180
Addition of a Class into a Package......Page 182
Package Scope......Page 185
The Class Path......Page 187
Setting the Class Path......Page 188
Comment Insertion......Page 189
Class Comments......Page 190
General Comments......Page 191
Package and Overview Comments......Page 192
Comment Extraction......Page 193
Class Design Hints......Page 194
5 INHERITANCE......Page 198
Classes, Superclasses, and Subclasses......Page 199
Polymorphism......Page 206
Dynamic Binding......Page 208
Preventing Inheritance: Final Classes and Methods......Page 210
Casting......Page 211
Abstract Classes......Page 213
Protected Access......Page 218
Object: The Cosmic Superclass......Page 219
The equals Method......Page 220
Equality Testing and Inheritance......Page 221
The hashCode Method......Page 223
The toString Method......Page 225
Generic Array Lists......Page 231
Accessing Array List Elements......Page 233
Compatibility between Typed and Raw Array Lists......Page 237
Object Wrappers and Autoboxing......Page 238
Methods with a Variable Number of Parameters......Page 241
Enumeration Classes......Page 242
The Class Class......Page 244
A Primer on Catching Exceptions......Page 246
Using Reflection to Analyze the Capabilities of Classes......Page 248
Using Reflection to Analyze Objects at Runtime......Page 253
Using Reflection to Write Generic Array Code......Page 258
Method Pointers!......Page 261
Design Hints for Inheritance......Page 265
6 INTERFACES AND INNER CLASSES......Page 268
Interfaces......Page 269
Properties of Interfaces......Page 274
Interfaces and Abstract Classes......Page 275
Object Cloning......Page 276
Interfaces and Callbacks......Page 282
Inner Classes......Page 285
Use of an Inner Class to Access Object State......Page 287
Special Syntax Rules for Inner Classes......Page 290
Are Inner Classes Useful? Actually Necessary? Secure?......Page 291
Local Inner Classes......Page 293
Accessing final Variables from Outer Methods......Page 294
Anonymous Inner Classes......Page 296
Static Inner Classes......Page 298
Proxies......Page 302
Properties of Proxy Classes......Page 306
7 GRAPHICS PROGRAMMING......Page 308
Introducing Swing......Page 309
Creating a Frame......Page 312
Positioning a Frame......Page 315
Determining a Good Frame Size......Page 317
Displaying Information in a Component......Page 321
Working with 2D Shapes......Page 326
Using Color......Page 334
Using Special Fonts for Text......Page 337
Displaying Images......Page 345
8 EVENT HANDLING......Page 350
Basics of Event Handling......Page 351
Example: Handling a Button Click......Page 353
Becoming Comfortable with Inner Classes......Page 358
Example: Changing the Look and Feel......Page 361
Adapter Classes......Page 365
Actions......Page 369
Mouse Events......Page 376
The AWT Event Hierarchy......Page 384
Semantic and Low-Level Events......Page 385
9 USER INTERFACE COMPONENTS WITH SWING......Page 388
Design Patterns......Page 389
The Model-View-Controller Pattern......Page 390
A Model-View-Controller Analysis of Swing Buttons......Page 394
Introduction to Layout Management......Page 395
Border Layout......Page 398
Grid Layout......Page 400
Text Input......Page 404
Text Fields......Page 405
Labels and Labeling Components......Page 406
Text Areas......Page 408
Scroll Panes......Page 409
Checkboxes......Page 412
Radio Buttons......Page 415
Borders......Page 419
Combo Boxes......Page 423
Sliders......Page 427
Menu Building......Page 433
Icons in Menu Items......Page 435
Checkbox and Radio Button Menu Items......Page 436
Pop-Up Menus......Page 437
Keyboard Mnemonics and Accelerators......Page 439
Enabling and Disabling Menu Items......Page 441
Toolbars......Page 446
Tooltips......Page 448
Sophisticated Layout Management......Page 451
The Grid Bag Layout......Page 453
Group Layout......Page 463
Using No Layout Manager......Page 472
Custom Layout Managers......Page 473
Traversal Order......Page 477
Dialog Boxes......Page 479
Option Dialogs......Page 480
Creating Dialogs......Page 489
Data Exchange......Page 494
File Dialogs......Page 501
Color Choosers......Page 512
10 DEPLOYING APPLICATIONS AND APPLETS......Page 520
JAR Files......Page 521
The Manifest......Page 522
Executable JAR Files......Page 523
Resources......Page 524
Sealing......Page 527
Java Web Start......Page 528
The Sandbox......Page 531
Signed Code......Page 532
The JNLP API......Page 534
A Simple Applet......Page 543
The Applet HTML Tag and Its Attributes......Page 548
Use of Parameters to Pass Information to Applets......Page 551
Accessing Image and Audio Files......Page 557
The Applet Context......Page 558
Property Maps......Page 566
The Preferences API......Page 571
11 EXCEPTIONS, LOGGING, ASSERTIONS, AND DEBUGGING......Page 578
Dealing with Errors......Page 579
The Classification of Exceptions......Page 580
Declaring Checked Exceptions......Page 582
How to Throw an Exception......Page 584
Creating Exception Classes......Page 585
Catching Exceptions......Page 586
Catching Multiple Exceptions......Page 588
Rethrowing and Chaining Exceptions......Page 589
The finally Clause......Page 590
Analyzing Stack Trace Elements......Page 593
Tips for Using Exceptions......Page 595
Using Assertions......Page 598
Assertion Enabling and Disabling......Page 599
Using Assertions for Parameter Checking......Page 600
Using Assertions for Documenting Assumptions......Page 601
Basic Logging......Page 602
Advanced Logging......Page 603
Changing the Log Manager Configuration......Page 605
Handlers......Page 606
A Logging Recipe......Page 610
Debugging Tips......Page 618
Using a Console Window......Page 624
Tracing AWT Events......Page 625
Letting the AWT Robot Do the Work......Page 630
Using a Debugger......Page 634
12 GENERIC PROGRAMMING......Page 640
Why Generic Programming?......Page 641
Who Wants to Be a Generic Programmer?......Page 642
Definition of a Simple Generic Class......Page 643
Generic Methods......Page 645
Bounds for Type Variables......Page 646
Generic Code and the Virtual Machine......Page 648
Translating Generic Expressions......Page 649
Translating Generic Methods......Page 650
Calling Legacy Code......Page 652
You Cannot Throw or Catch Instances of a Generic Class......Page 653
Arrays of Parameterized Types Are Not Legal......Page 654
You Cannot Instantiate Type Variables......Page 655
Beware of Clashes After Erasure......Page 656
Inheritance Rules for Generic Types......Page 657
Wildcard Types......Page 659
Supertype Bounds for Wildcards......Page 661
Wildcard Capture......Page 663
Reflection and Generics......Page 667
Generic Type Information in the Virtual Machine......Page 668
13 COLLECTIONS......Page 676
Separating Collection Interfaces and Implementation......Page 677
Collection and Iterator Interfaces in the Java Library......Page 680
Concrete Collections......Page 685
Linked Lists......Page 686
Hash Sets......Page 695
Tree Sets......Page 699
Object Comparison......Page 700
Queues and Deques......Page 705
Priority Queues......Page 706
Maps......Page 707
Specialized Set and Map Classes......Page 712
The Collections Framework......Page 716
Views and Wrappers......Page 720
Bulk Operations......Page 726
Algorithms......Page 727
Sorting and Shuffling......Page 728
Binary Search......Page 731
Simple Algorithms......Page 732
Writing Your Own Algorithms......Page 733
Legacy Collections......Page 734
Enumerations......Page 735
Stacks......Page 736
Bit Sets......Page 737
14 MULTITHREADING......Page 742
What Are Threads?......Page 743
Using Threads to Give Other Tasks a Chance......Page 749
Interrupting Threads......Page 755
Thread States......Page 757
Blocked and Waiting Threads......Page 758
Thread Priorities......Page 760
Daemon Threads......Page 761
Handlers for Uncaught Exceptions......Page 762
An Example of a Race Condition......Page 763
The Race Condition Explained......Page 767
Lock Objects......Page 769
Condition Objects......Page 772
The synchronized Keyword......Page 777
Synchronized Blocks......Page 781
The Monitor Concept......Page 782
Volatile Fields......Page 783
Deadlocks......Page 784
Lock Testing and Timeouts......Page 787
Read/Write Locks......Page 788
Why the stop and suspend Methods Are Deprecated......Page 789
Blocking Queues......Page 791
Efficient Maps, Sets, and Queues......Page 798
Older Thread-Safe Collections......Page 800
Callables and Futures......Page 801
Executors......Page 805
Thread Pools......Page 806
Scheduled Execution......Page 810
Controlling Groups of Tasks......Page 811
Synchronizers......Page 812
Countdown Latches......Page 813
Synchronous Queues......Page 814
Example: Pausing and Resuming an Animation......Page 815
Threads and Swing......Page 821
Running Time-Consuming Tasks......Page 822
Using the Swing Worker......Page 826
The Single-Thread Rule......Page 833
Appendix......Page 836
A......Page 840
C......Page 842
E......Page 845
G......Page 847
I......Page 849
J......Page 850
L......Page 854
M......Page 855
N......Page 856
P......Page 857
R......Page 858
S......Page 859
T......Page 861
V......Page 862
X......Page 863
โฆ Subjects
Computer Science;Programming;Reference;Nonfiction;Software;Science;Technology;Technical;Textbooks;Computers;Engineering
๐ SIMILAR VOLUMES
Core Javaยฎ has long been recognized as the leading, no-nonsense tutorial and reference for experienced programmers who want to write robust Java code for real-world applications. Now, Core Javaยฎ, Volume IโFundamentals, Tenth Edition, has been extensively updated to reflect the most eagerly awaited a
<span>The #1 Java Guide for Serious Programmers: Fully Updated through Java 17</span><span> </span><span><br></span><p><span>"This is the definitive reference and instructional work for Java and the Java ecosystem."</span></p><p><span>---Andrew Binstock</span><span>, </span><span>Java Magazine</span