Product Description
PRACTICAL, EXAMPLE-RICH COVERAGE OF:
* Classes, Objects, Encapsulation, Inheritance, Polymorphism, Interfaces, Nested Classes
* Integrated OOP Case Studies: Time, GradeBook, Employee
* Industrial-Strength, 95-Page OOD/UML® 2 ATM Case Study
* JavaServer™ Faces, Ajax-Enabled Web Applications, Web Services, Networking
* JDBC™, SQL, Java DB, MySQL®
* Threads and the Concurrency APIs
* I/O, Types, Control Statements, Methods
* Arrays, Generics, Collections
* Exception Handling, Files
* GUI, Graphics, GroupLayout, JDIC
* Using the Debugger and the API Docs
* And more…
VISIT WWW.DEITEL.COM
* For information on Deitel’s Dive Into® Series corporate training courses offered at customer sites worldwide (or write to deitel@deitel.com)
* Download code examples
* Check out the growing list of programming, Web 2.0, and software-related Resource Centers
* To receive updates for this book, subscribe to the free DEITEL® BUZZ ONLINE e-mail newsletter at www.deitel.com/newsletter/subscribe.html
* Read archived issues of the DEITEL® BUZZ ONLINE
The practicing programmer’s DEITEL® guide to Java™ development and the Powerful Java™ Platform
Written for programmers with a background in high-level language programming, this book applies the Deitel signature live-code approach to teaching programming and explores the Java language and Java APIs in depth. The book presents the concepts in the context of fully tested programs, complete with syntax shading, code highlighting, line-by-line code descriptions and program outputs. The book features 220 Java applications with over 18,000 lines of proven Java code, and hundreds of tips that will help you build robust applications.
Start with an introduction to Java using an early classes and objects approach, then rapidly move on to more advanced topics, including GUI, graphics, exception handling, generics, collections, JDBC™, web-application development with JavaServer™ Faces, web services and more. You’ll enjoy the Deitels’ classic treatment of object-oriented programming and the OOD/UML® ATM case study, including a complete Java implementation. When you’re finished, you’ll have everything you need to build object-oriented Java applications.
The DEITEL® Developer Series is designed for practicing programmers. The series presents focused treatments of emerging technologies, including Java™, C++, .NET, web services, Internet and web development and more.
PRE-PUBLICATION REVIEWER TESTIMONIALS
“Presenting software engineering side by side with core Java concepts is highly refreshing; gives readers insight into how professional software is developed.”—Clark Richey (Java Champion), RABA Technologies, LLC.
“The quality of the design and code examples is second to none!”—Terrell Hull, Enterprise Architect
“The JDBC chapter is very hands on. I like the fact that Java DB/Apache Derby is used in the examples, which makes it really simple to learn and understand JDBC.”—Sandeep Konchady, Sun Microsystems
“Equips you with the latest web application technologies. Examples are impressive and real! Want to develop a simple address locator with Ajax and JSF? Jump to Chapter 22.”—Vadiraj Deshpande, Sun Microsystems
“Covers web services with Java SE 6 and Java EE 5 in a real-life, example-based, friendly approach. The Deitel Web Services Resource Center is really good, even for advanced developers.”—Sanjay Dhamankar, Sun Microsystems
“Mandatory book for any serious Java EE developer looking for improved productivity: JSF development, visual web development and web services development have never been easier.”—Ludovic Chapenois, Sun Microsystems
“I teach Java programming and object-oriented analysis and design. The OOD/UML 2 case study is the best presentation of the ATM example I have seen.”—Craig W. Slinkman, University of Texas–Arlington
“Introduces OOP and UML 2 early. The conceptual level is perfect. No other book comes close to its quality of organization and presentation. The live-code approach to presenting exemplary code makes a big difference in the learning outcome.”—Walt Bunch, Chapman University/
Table of Contents
Preface xxiii
Before You Begin xxxiii
Chapter 1: Introduction 1
1.1 Introduction 2
1.2 The Internet and the World Wide Web 3
1.3 History of C and C++ 3
1.4 History of Java 4
1.5 Java Class Libraries 4
1.6 Typical Java Development Environment 5
1.7 Notes about Java and Java for Programmers 8
1.8 Test-Driving a Java Application 9
1.9 Software Engineering Case Study: Introduction to Object Technology and the UML 13
1.10 Web 2.0 17
1.11 Software Technologies 18
1.12 Wrap-Up 19
1.13 Web Resources 20
Chapter 2: Introduction to Java Applications 22
2.1 Introduction 23
2.2 A First Program in Java: Printing a Line of Text 23
2.3 Modifying Our First Java Program 29
2.4 Displaying Text with printf 32
2.5 Another Java Application: Adding Integers 33
2.6 Arithmetic 37
2.7 Decision Making: Equality and Relational Operators 39
2.8 (Optional) Software Engineering Case Study: Examining the Requirements Document 44
2.9 Wrap-Up 53
Chapter 3: Introduction to Classes and Objects 54
3.1 Introduction 55
3.2 Classes, Objects, Methods and Instance Variables 55
3.3 Declaring a Class with a Method and Instantiating an Object of a Class 57
3.4 Declaring a Method with a Parameter61
3.5 Instance Variables, set Methods and get Methods 64
3.6 Primitive Types vs. Reference Types 69
3.7 Initializing Objects with Constructors 70
3.8 Floating-Point Numbers and Type double 73
3.9 (Optional) Software Engineering Case Study: Identifying the Classes in a Requirements Document 78
3.10 Wrap-Up 86
Chapter 4: Control Statements: Part 1 87
4.1 Introduction 88
4.2 Control Structures 88
4.3 if Single-Selection Statement 91
4.4 if…else Double-Selection Statement 91
4.5 while Repetition Statement 95
4.6 Counter-Controlled Repetition 96
4.7 Sentinel-Controlled Repetition 100
4.8 Nested Control Statements 106
4.9 Compound Assignment Operators 109
4.10 Increment and Decrement Operators 109
4.11 Primitive Types 112
4.12 (Optional) Software Engineering Case Study: Identifying Class Attributes 113
4.13 Wrap-Up 118
Chapter 5: Control Statements: Part 2 119
5.1 Introduction 120
5.2 Essentials of Counter-Controlled Repetition 120
5.3 for Repetition Statement 122
5.4 Examples Using the for Statement 125
5.5 do…while Repetition Statement 130
5.6 switch Multiple-Selection Statement 132
5.7 break and continue Statements 139
5.8 Logical Operators 141
5.9 (Optional) Software Engineering Case Study: Identifying Objects’ States and Activities 147
5.10 Wrap-Up 152
Chapter 6: Methods: A Deeper Look 153
6.1 Introduction 154
6.2 Program Modules in Java 155
6.3 static Methods, static Fields and Class Math 155
6.4 Declaring Methods with Multiple Parameters 158
6.5 Notes on Declaring and Using Methods 162
6.6 Method-Call Stack and Activation Records 163
6.7 Argument Promotion and Casting 164
6.8 Java API Packages 165
6.9 Case Study: Random-Number Generation 167
6.10 Case Study: A Game of Chance (Introducing Enumerations) 173
6.11 Scope of Declarations 177
6.12 Method Overloading 180
6.13 Introduction to Recursion 183
6.14 Recursion Concepts 184
6.15 Example Using Recursion: Factorials 184
6.16 Example Using Recursion: Fibonacci Series 187
6.17 Recursion and the Method-Call Stack 190
6.18 Recursion vs. Iteration 192
6.19 (Optional) Software Engineering Case Study: Identifying Class Operations 194
6.20 Wrap-Up 201
Chapter 7: Arrays 202
7.1 Introduction 203
7.2 Arrays 203
7.3 Declaring and Creating Arrays 205
7.4 Examples Using Arrays 206
7.5 Case Study: Card Shuffling and Dealing Simulation 215
7.6 Enhanced for Statement 219
7.7 Passing Arrays to Methods 220
7.8 Case Study: Class GradeBook Using an Array to Store Grades 224
7.9 Multidimensional Arrays 229
7.10 Case Study: Class GradeBook Using a Two-Dimensional Array 233
7.11 Variable-Length Argument Lists 239
7.12 Using Command-Line Arguments 240
7.13 (Optional) Software Engineering Case Study: Collaboration Among Objects 242
7.14 Wrap-Up 249
Chapter 8: Classes and Objects: A Deeper Look 251
8.1 Introduction 252
8.2 Time Class Case Study 253
8.3 Controlling Access to Members 256
8.4 Referring to the Current Object’s Members with the this Reference 257
8.5 Time Class Case Study: Overloaded Constructors 259
8.6 Default and No-Argument Constructors 265
8.7 Notes on Set and Get Methods 266
8.8 Composition 267
8.9 Enumerations 270
8.10 Garbage Collection and Method finalize 273
8.11 static Class Members 274
8.12 static Import 278
8.13 final Instance Variables 279
8.14 Software Reusability 282
8.15 Data Abstraction and Encapsulation 283
8.16 Time Class Case Study: Creating Packages 284
8.17 Package Access 290
8.18 (Optional) Software Engineering Case Study: Starting to Program the Classes of the ATM System 291
8.19 Wrap-Up 297
Chapter 9: Object-Oriented Programming: Inheritance 298
9.1 Introduction 299
9.2 Superclasses and Subclasses 300
9.3 protected Members 302
9.4 Relationship between Superclasses and Subclasses 303
9.5 Constructors in Subclasses 327
9.6 Software Engineering with Inheritance 333
9.7 Object Class 333
9.8 Wrap-Up 335
Chapter 10: Object-Oriented Programming: Polymorphism 336
10.1 Introduction 337
10.2 Polymorphism Examples 339
10.3 Demonstrating Polymorphic Behavior 340
10.4 Abstract Classes and Methods 342
10.5 Case Study: Payroll System Using Polymorphism 345
10.6 final Methods and Classes 360
10.7 Case Study: Creating and Using Interfaces 361
10.8 (Optional) Software Engineering Case Study: Incorporating Inheritance into the ATM System 373
10.9 Wrap-Up 380
Chapter 11: GUI Components: Part 1 381
11.1 Introduction 382
11.2 Simple GUI-Based Input/Output with JOptionPane 383
11.3 Overview of Swing Components 386
11.4 Displaying Text and Images in a Window 389
11.5 Text Fields and an Introduction to Event Handling with Nested Classes 393
11.6 Common GUI Event Types and Listener Interfaces 400
11.7 How Event Handling Works 401
11.8 JButton 404
11.9 Buttons That Maintain State 407
11.10 JComboBox and Using an Anonymous Inner Class for Event Handling 413
11.11 JList 417
11.12 Multiple-Selection Lists 420
11.13 Mouse Event Handling 422
11.14 Adapter Classes 427
11.15 JPanel Subclass for Drawing with the Mouse 430
11.16 Key-Event Handling 434
11.17 Layout Managers 438
11.18 Using Panels to Manage More Complex Layouts 447
11.19 JTextArea 449
11.20 Wrap-Up 452
Chapter 12: Graphics and Java 2D™ 453
12.1 Introduction 454
12.2 Graphics Contexts and Graphics Objects 456
12.3 Color Control 457
12.4 Font Control 464
12.5 Drawing Lines, Rectangles and Ovals 470
12.6 Drawing Arcs 474
12.7 Drawing Polygons and Polylines 476
12.8 Java 2D API 479
12.9 Wrap-Up 486
Chapter 13: Exception Handling 487
13.1 Introduction 488
13.2 Exception-Handling Overview 489
13.3 Example: Divide by Zero without Exception Handling 490
13.4 Example: Handling ArithmeticExceptions and InputMismatchExceptions 492
13.5 When to Use Exception Handling 497
13.6 Java Exception Hierarchy 498
13.7 finally Block 500
13.8 Stack Unwinding 505
13.9 printStackTrace, getStackTrace and getMessage 506
13.10 Chained Exceptions 509
13.11 Declaring New Exception Types 511
13.12 Preconditions and Postconditions 512
13.13 Assertions 512
13.14 Wrap-Up 514
Chapter 14: Files and Streams 515
14.1 Introduction 516
14.2 Data Hierarchy 517
14.3 Files and Streams 519
14.4 Class File 520
14.5 Sequential-Access Text Files 525
14.6 Object Serialization 540
14.7 Additional java.io Classes 550
14.8 Opening Files with JFileChooser 552
14.9 Wrap-Up 555
Chapter 15: Generics 556
15.1 Introduction 557
15.2 Motivation for Generic Methods 558
15.3 Generic Methods: Implementation and Compile-Time Translation 560
15.4 Additional Compile-Time Translation Issues: Methods That Use a Type Parameter as the Return Type 563
15.5 Overloading Generic Methods 566
15.6 Generic Classes 567
15.7 Raw Types 577
15.8 Wildcards in Methods That Accept Type Parameters 581
15.9 Generics and Inheritance: Notes 585
15.10 Wrap-Up 586
15.11 Internet and Web Resources 586
Chapter 16: Collections 587
16.1 Introduction 588
16.2 Collections Overview 589
16.3 Class Arrays 590
16.4 Interface Collection and Class Collections 593
16.5 Lists 594
16.6 Collections Algorithms 605
16.7 Stack Class of Package java.util 618
16.8 Class PriorityQueue and Interface Queue 621
16.9 Sets 622
16.10 Maps 625
16.11 Properties Class 629
16.12 Synchronized Collections 632
16.13 Unmodifiable Collections 633
16.14 Abstract Implementations 634
16.15 Wrap-Up 634
Chapter 17: GUI Components: Part 2 635
17.1 Introduction 636
17.2 JSlider 636
17.3 Windows: Additional Notes 640
17.4 Using Menus with Frames 641
17.5 JPopupMenu 649
17.6 Pluggable Look-and-Feel 652
17.7 JDesktopPane and JInternalFrame 656
17.8 JTabbedPane 660
17.9 Layout Managers: BoxLayout and GridBagLayout 662
17.10 Wrap-Up 675
Chapter 18: Multithreading 676
18.1 Introduction 677
18.2 Thread States: Life Cycle of a Thread 679
18.3 Thread Priorities and Thread Scheduling 681
18.4 Creating and Executing Threads 683
18.5 Thread Synchronization 687
18.6 Producer/Consumer Relationship without Synchronization 696
18.7 Producer/Consumer Relationship: ArrayBlockingQueue 703
18.8 Producer/Consumer Relationship with Synchronization 706
18.9 Producer/Consumer Relationship: Bounded Buffers 712
18.10 Producer/Consumer Relationship: The Lock and Condition Interfaces 720
18.11 Multithreading with GUI 726
18.12 Other Classes and Interfaces in java.util.concurrent 741
18.13 Wrap-Up 741
Chapter 19: Networking 743
19.1 Introduction 744
19.2 Manipulating URLs 745
19.3 Reading a File on a Web Server 750
19.4 Establishing a Simple Server Using Stream Sockets 753
19.5 Establishing a Simple Client Using Stream Sockets 755
19.6 Client/Server Interaction with Stream Socket Connections 756
19.7 Connectionless Client/Server Interaction with Datagrams 768
19.8 Client/Server Tic-Tac-Toe Using a Multithreaded Server 775
19.9 Security and the Network 790
19.10 [Web Bonus] Case Study: DeitelMessenger Server and Client 790
19.11 Wrap-Up 790
Chapter 20: Accessing Databases with JDBC 791
20.1 Introduction 792
20.2 Relational Databases 793
20.3 Relational Database Overview: The books Database 794
20.4 SQL 797
20.5 Instructions for Installing MySQL and MySQL Connector/J 806
20.6 Instructions for Setting Up a MySQL User Account 807
20.7 Creating Database books in MySQL 808
20.8 Manipulating Databases with JDBC 809
20.9 RowSet Interface 825
20.10 Java DB/Apache Derby 828
20.11 PreparedStatements 829
20.12 Stored Procedures 844
20.13 Transaction Processing 845
20.14 Wrap-Up 846
20.15 Web Resources 846
Chapter 21: JavaServer™ Faces Web Applications 847
21.1 Introduction 848
21.2 Simple HTTP Transactions 849
21.3 Multitier Application Architecture 852
21.4 Java Web Technologies 853
21.5 Creating and Running a Simple Application in Netbeans 857
21.6 JSF Components 870
21.7 Session Tracking 883
21.8 Wrap-Up 905
Chapter 22: Ajax-Enabled JavaServer™ Faces Web Applications 906
22.1 Introduction 907
22.2 Accessing Databases in Web Applications 907
22.3 Ajax-Enabled JSF Components 920
22.4 Creating an Autocomplete Text Field and Using Virtual Forms 922
22.5 Wrap-Up 932
Chapter 23: JAX-WS Web Services 933
23.1 Introduction 934
23.2 Java Web Services Basics 936
23.3 Creating, Publishing, Testing and Describing a Web Service 936
23.4 Consuming a Web Service 946
23.5 SOAP 955
23.6 Session Tracking in Web Services 957
23.7 Consuming a Database-Driven Web Service from a Web Application 973
23.8 Passing an Object of a User-Defined Type to a Web Service 982
23.9 Wrap-Up 992
Chapter 24: Formatted Output 993
24.1 Introduction 994
24.2 Streams 994
24.3 Formatting Output with printf 994
24.4 Printing Integers 995
24.5 Printing Floating-Point Numbers 996
24.6 Printing Strings and Characters 998
24.7 Printing Dates and Times 999
24.8 Other Conversion Characters 1002
24.9 Printing with Field Widths and Precisions 1003
24.10 Using Flags in the printf Format String 1005
24.11 Printing with Argument Indices 1009
24.12 Printing Literals and Escape Sequences 1010
24.13 Formatting Output with Class Formatter 1010
24.14 Wrap-Up 1012
Chapter 25: Strings, Characters and Regular Expressions 1013
25.1 Introduction 1014
25.2 Fundamentals of Characters and Strings 1014
25.3 Class String 1015
25.4 Class StringBuilder 1028
25.5 Class Character 1035
25.6 Class StringTokenizer 1039
25.7 Regular Expressions, Class Pattern and Class Matcher 1041
25.8 Wrap-Up 1049
Appendix A: Operator Precedence Chart 1050
A.1 Operator Precedence 1050
Appendix B: ASCII Character Set 1052
Appendix C: Keywords and Reserved Words 1053
Appendix D: Primitive Types 1054
Appendix E: GroupLayout 1055
E.1 Introduction 1055
E.2 GroupLayout Basics 1055
E.3 Building a ColorChooser 1056
E.4 GroupLayout Web Resources 1066
Appendix F: Java Desktop Integration Components (JDIC) 1067
F.1 Introduction 1067
F.2 Splash Screens 1067
F.3 Desktop Class 1069
F.4 Tray Icons 1072
F.5 JDIC Incubator Projects 1072
F.6 JDIC Demos 1072
Appendix G: Using the Java API Documentation 1073
G.1 Introduction 1073
G.2 Navigating the Java API 1074
Appendix H: ATM Case Study Code 1082
H.1 ATM Case Study Implementation 1082
H.2 Class ATM 1083
H.3 Class Screen 1088
H.4 Class Keypad 1089
H.5 Class CashDispenser 1090
H.6 Class DepositSlot 1091
H.7 Class Account 1092
H.8 Class BankDatabase 1094
H.9 Class Transaction 1097
H.10 Class BalanceInquiry 1098
H.11 Class Withdrawal 1098
H.12 Class Deposit 1103
H.13 Class ATMCaseStudy 1106
H.14 Wrap-Up 1106
Appendix I: UML 2: Additional Diagram Types 1107
I.1 Introduction 1107
I.2 Additional Diagram Types 1107
Appendix J: Using the Debugger 1109
J.1 Introduction 1110
J.2 Breakpoints and the run, stop, cont and print Commands 1110
J.3 The print and set Commands 1114
J.4 Controlling Execution Using the step, step up and next Commands 1116
J.5 The watch Command 1119
J.6 The clear Command 1121
J.7 Wrap-Up 1124
Index 1125
About the Author
Paul J. Deitel and Dr. Harvey M. Deitel are the founders of Deitel & Associates, Inc., the internationally recognized programming languages content-creation, corporate-training and Internet business development organization. The Deitels have written many international best-selling programming languages professional books and textbooks that millions of people worldwide have used to master Java™, C++, C, C#, XML, Visual Basic®, Perl, Python and Internet and web programming.
Product Details
* Paperback: 1200 pages
* Publisher: Prentice Hall PTR; 1 edition (February 22, 2009)
* Language: English
* ISBN-10: 0137001290
* ISBN-13: 978-0137001293
PDF Here:
Code: http://uploading.com/files/94ESJUVE/0137001290_Java_for_Pro.rar.html |
http://rapidshare.com/files/245702378/0137001290_Java_for_Pro.rar |
CHM Here:
Code: http://uploading.com/files/UFJZSU93/0137001290_Java_For_Pro_CHM.chm.html |
http://rapidshare.com/files/245702898/0137001290_Java_For_Pro_CHM.chm |
No comments:
Post a Comment