Share E-Book

Java how to program. Early objects (Harvey Deitel, Paul Deitel) (z-library.sk, 1lib.sk, z-lib.sk)

Author Harvey Deitel, Paul Deitel

java
Language English

No Description

Format PDF
Size 18.3 MB
1
Views
0
Downloads
0.00
Total Donations
(First 20 pages)

Registered users can read the full content for free

Register as a Gaohf Library member to read the complete e-book online for free and enjoy a better reading experience.

Page 1
(This page has no text content)
Page 2
(This page has no text content)
Page 3
Java™ How to Program Early Objects ELEVENTH EDITION
Page 4
Deitel Series Page How To Program Series Android™ How to Program, 3/E C++ How to Program, 10/E C How to Program, 8/E Java™ How to Program, Early Objects Version, 11/E Java™ How to Program, Late Objects Version, 11/E Internet & World Wide Web How to Program, 5/E Visual Basic 2012 How to Program, 6/E Visual C# How to Program, 6/E Deitel® Developer Series Android™ 6 for Programmers: An App-Driven Approach, 3/E C for Programmers with an Introduction to C11 ® ® ®
Page 5
C++11 for Programmers C# 6 for Programmers Java™ for Programmers, 4/E JavaScript for Programmers Swift™ for Programmers Simply Series Simply Visual Basic 2010: An App-Driven Approach, 4/E Simply C++: An App-Driven Tutorial Approach VitalSource Web Books http://bit.ly/DeitelOnVitalSource Android™ How to Program, 2/E and 3/E C++ How to Program, 9/E and 10/E Java™ How to Program, 10/E and 11/E Simply C++: An App-Driven Tutorial Approach Simply Visual Basic 2010: An App-Driven Approach, 4/E ® ® ®
Page 6
Visual Basic 2012 How to Program, 6/E Visual C# How to Program, 6/E Visual C# 2012 How to Program, 5/E LiveLessons Video Learning Products http://deitel.com/books/LiveLessons/ Android™ 6 App Development Fundamentals, 3/E C++ Fundamentals Java SE 8™ Fundamentals, 2/E Java SE 9™ Fundamentals, 3/E C# 6 Fundamentals C# 2012 Fundamentals JavaScript Fundamentals Swift™ Fundamentals REVEL™ Interactive Multimedia ® ® ®
Page 7
REVEL™ for Deitel Java™ To receive updates on Deitel publications, Resource Centers, training courses, partner offers and more, please join the Deitel communities on Facebook —http://facebook.com/DeitelFan Twitter —http://twitter.com/deitel LinkedIn —http://linkedin.com/company/deitel-&- associates YouTube™—http://youtube.com/DeitelTV Google+™—http://google.com/+DeitelFan Instagram —http://instagram.com/DeitelFan and register for the free Deitel Buzz Online e-mail newsletter at: http://www.deitel.com/newsletter/subscribe.html To communicate with the authors, send e-mail to: deitel@deitel.com For information on programming-languages corporate training seminars offered by Deitel & Associates, Inc. worldwide, write to deitel@deitel.com or visit: http://www.deitel.com/training/ ® ® ® ® ®
Page 8
For continuing updates on Pearson/Deitel publications visit: http://www.deitel.com http://www.pearsonhighered.com/deitel/ Visit the Deitel Resource Centers, which will help you master programming languages, software development, Android™ and iOS app development, and Internet- and web-related topics: http://www.deitel.com/ResourceCenters.html ®
Page 9
Java™ How to Program Early Objects ELEVENTH EDITION Paul Deitel Deitel & Associates, Inc. Harvey Deitel Deitel & Associates, Inc. 330 Hudson Street, NY, NY, 10013
Page 10
Trademarks Deitel and the double-thumbs-up bug are registered trademarks of Deitel and Associates, Inc. Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners. 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.
Page 11
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 and Windows are registered trademarks of the Microsoft Corporation in the U.S.A. and other countries. Screen shots and icons reprinted with permission from the Microsoft Corporation. This book is not sponsored or endorsed by or affiliated with the Microsoft Corporation. UNIX is a registered trademark of The Open Group. Apache is a trademark of The Apache Software Foundation. CSS and XML are registered trademarks of the World Wide Web Consortium. Firefox is a registered trademark of the Mozilla Foundation. Google is a trademark of Google, Inc. Mac and macOS are trademarks of Apple Inc., registered in the U.S. and other countries. Linux is a registered trademark of Linus Torvalds. All trademarks are property of their respective owners. Throughout this book, trademarks are used. Rather than put a trademark symbol in every occurrence of a trademarked name, we state that we are using the names in an editorial fashion
Page 12
only and to the benefit of the trademark owner, with no intention of infringement of the trademark.
Page 13
Contents The online chapters and appendices listed at the end of this Table of Contents are located on the book’s Companion Website (http://www.pearsonhighered.com/ deitel/)—see the inside front cover of your book for details. 1. Foreword xxv 2. Preface xxvii 3. Before You Begin xlvii 1. 1 Introduction to Computers, the Internet and Java 1 1. 1.1 Introduction 2 2. 1.2 Hardware and Software 4 1. 1.2.1 Moore’s Law 4 2. 1.2.2 Computer Organization 5 3. 1.3 Data Hierarchy 7 4. 1.4 Machine Languages, Assembly Languages and High-Level Languages 9 5. 1.5 Introduction to Object Technology 10 1. 1.5.1 Automobile as an Object 11 2. 1.5.2 Methods and Classes 11 3. 1.5.3 Instantiation 11
Page 14
4. 1.5.4 Reuse 11 5. 1.5.5 Messages and Methopd Calls 12 6. 1.5.6 Attributes and Instance Variables 12 7. 1.5.7 Encapsulation and Information Hiding 12 8. 1.5.8 Inheritance 12 9. 1.5.9 Interfaces 13 10. 1.5.10 Object-Oriented Analysis and Design (OOAD) 13 11. 1.5.11 The UML (Unified Modeling Language) 13 6. 1.6 Operating Systems 14 1. 1.6.1 Windows—A Proprietary Operating System 14 2. 1.6.2 Linux—An Open-Source Operating System 14 3. 1.6.3 Apple’s macOS and Apple’s iOS for iPhone , iPad and iPod Touch Devices 15 4. 1.6.4 Google’s Android 15 7. 1.7 Programming Languages 16 8. 1.8 Java 18 9. 1.9 A Typical Java Development Environment 19 10. 1.10 Test-Driving a Java Application 22 11. 1.11 Internet and World Wide Web 26 1. 1.11.1 Internet: A Network of Networks 27 2. 1.11.2 World Wide Web: Making the Internet User- Friendly 27 3. 1.11.3 Web Services and Mashups 27 4. 1.11.4 Internet of Things 28 12. 1.12 Software Technologies 29 ®
Page 15
13. 1.13 Getting Your Questions Answered 31 2. 2 Introduction to Java Applications; Input/Output and Operators 35 1. 2.1 Introduction 36 2. 2.2 Your First Program in Java: Printing a Line of Text 36 1. 2.2.1 Compiling the Application 40 2. 2.2.2 Executing the Application 41 3. 2.3 Modifying Your First Java Program 42 4. 2.4 Displaying Text with printf 44 5. 2.5 Another Application: Adding Integers 45 1. 2.5.1 import Declarations 46 2. 2.5.2 Declaring and Creating a Scanner to Obtain User Input from the Keyboard 46 3. 2.5.3 Prompting the User for Input 47 4. 2.5.4 Declaring a Variable to Store an Integer and Obtaining an Integer from the Keyboard 47 5. 2.5.5 Obtaining a Second Integer 48 6. 2.5.6 Using Variables in a Calculation 48 7. 2.5.7 Displaying the Calculation Result 48 8. 2.5.8 Java API Documentation 49 9. 2.5.9 Declaring and Initializing Variables in Separate Statements 49 6. 2.6 Memory Concepts 49 7. 2.7 Arithmetic 50 8. 2.8 Decision Making: Equality and Relational Operators 54 9. 2.9 Wrap-Up 57
Page 16
3. 3 Introduction to Classes, Objects, Methods and Strings 68 1. 3.1 Introduction 69 2. 3.2 Instance Variables, set Methods and get Methods 70 1. 3.2.1 Account Class with an Instance Variable, and set and get Methods 70 2. 3.2.2 AccountTest Class That Creates and Uses an Object of Class Account 73 3. 3.2.3 Compiling and Executing an App with Multiple Classes 76 4. 3.2.4 Account UML Class Diagram 76 5. 3.2.5 Additional Notes on Class AccountTest 78 6. 3.2.6 Software Engineering with private Instance Variables and public set and get Methods 78 3. 3.3 Account Class: Initializing Objects with Constructors 79 1. 3.3.1 Declaring an Account Constructor for Custom Object Initialization 80 2. 3.3.2 Class AccountTest: Initializing Account Objects When They’re Created 81 4. 3.4 Account Class with a Balance; Floating-Point Numbers 82 1. 3.4.1 Account Class with a balance Instance Variable of Type double 83 2. 3.4.2 AccountTest Class to Use Class Account 85 5. 3.5 Primitive Types vs. Reference Types 88 6. 3.6 (Optional) GUI and Graphics Case Study: A Simple GUI 88 1. 3.6.1 What Is a Graphical User Interface? 90
Page 17
2. 3.6.2 JavaFX Scene Builder and FXML 90 3. 3.6.3 Welcome App—Displaying Text and an Image 90 4. 3.6.4 Opening Scene Builder and Creating the File Welcome.fxml 90 5. 3.6.5 Adding an Image to the Folder Containing Welcome.fxml 92 6. 3.6.6 Creating a VBox Layout Container 92 7. 3.6.7 Configuring the VBox 92 8. 3.6.8 Adding and Configuring a Label 92 9. 3.6.9 Adding and Configuring an ImageView 94 10. 3.6.10 Previewing the Welcome GUI 95 7. 3.7 Wrap-Up 96 4. 4 Control Statements: Part 1; Assignment, ++ and -- Operators 104 1. 4.1 Introduction 105 2. 4.2 Algorithms 105 3. 4.3 Pseudocode 106 4. 4.4 Control Structures 106 1. 4.4.1 Sequence Structure in Java 107 2. 4.4.2 Selection Statements in Java 108 3. 4.4.3 Iteration Statements in Java 108 4. 4.4.4 Summary of Control Statements in Java 108 5. 4.5 if Single-Selection Statement 109 6. 4.6 if…else Double-Selection Statement 110 1. 4.6.1 Nested if…else Statements 111 2. 4.6.2 Dangling-else Problem 112
Page 18
3. 4.6.3 Blocks 112 4. 4.6.4 Conditional Operator (?:) 113 7. 4.7 Student Class: Nested if…else Statements 113 8. 4.8 while Iteration Statement 116 9. 4.9 Formulating Algorithms: Counter-Controlled Iteration 118 10. 4.10 Formulating Algorithms: Sentinel-Controlled Iteration 122 11. 4.11 Formulating Algorithms: Nested Control Statements 129 12. 4.12 Compound Assignment Operators 133 13. 4.13 Increment and Decrement Operators 134 14. 4.14 Primitive Types 137 15. 4.15 (Optional) GUI and Graphics Case Study: Event Handling; Drawing Lines 138 1. 4.15.1 Test-Driving the Completed Draw Lines App 138 2. 4.15.2 Building the App’s GUI 139 3. 4.15.3 Preparing to Interact with the GUI Programmatically 143 4. 4.15.4 Class DrawLinesController 145 5. 4.15.5 Class DrawLines—The Main Application Class 147 16. 4.16 Wrap-Up 149 5. 5 Control Statements: Part 2; Logical Operators 164 1. 5.1 Introduction 165 2. 5.2 Essentials of Counter-Controlled Iteration 165 3. 5.3 for Iteration Statement 166 4. 5.4 Examples Using the for Statement 170
Page 19
1. 5.4.1 Application: Summing the Even Integers from 2 to 20 171 2. 5.4.2 Application: Compound-Interest Calculations 172 5. 5.5 do…while Iteration Statement 175 6. 5.6 switch Multiple-Selection Statement 176 7. 5.7 Class AutoPolicy Case Study: Strings in switch Statements 182 8. 5.8 break and continue Statements 185 1. 5.8.1 break Statement 185 2. 5.8.2 continue Statement 186 9. 5.9 Logical Operators 187 1. 5.9.1 Conditional AND (&&) Operator 187 2. 5.9.2 Conditional OR (||) Operator 188 3. 5.9.3 Short-Circuit Evaluation of Complex Conditions 189 4. 5.9.4 Boolean Logical AND (&) and Boolean Logical Inclusive OR (|) Operators 189 5. 5.9.5 Boolean Logical Exclusive OR (^) 190 6. 5.9.6 Logical Negation (!) Operator 190 7. 5.9.7 Logical Operators Example 191 10. 5.10 Structured-Programming Summary 193 11. 5.11 (Optional) GUI and Graphics Case Study: Drawing Rectangles and Ovals 198 12. 5.12 Wrap-Up 201 6. 6 Methods: A Deeper Look 212
Page 20
1. 6.1 Introduction 213 2. 6.2 Program Units in Java 213 3. 6.3 static Methods, static Fields and Class Math 215 4. 6.4 Methods with Multiple Parameters 217 5. 6.5 Notes on Declaring and Using Methods 221 6. 6.6 Method-Call Stack and Activation Records 222 1. 6.6.1 Method-Call Stack 222 2. 6.6.2 Stack Frames 222 3. 6.6.3 Local Variables and Stack Frames 222 4. 6.6.4 Stack Overflow 223 7. 6.7 Argument Promotion and Casting 223 8. 6.8 Java API Packages 224 9. 6.9 Case Study: Secure Random-Number Generation 226 10. 6.10 Case Study: A Game of Chance; Introducing enum Types 231 11. 6.11 Scope of Declarations 236 12. 6.12 Method Overloading 238 1. 6.12.1 Declaring Overloaded Methods 238 2. 6.12.2 Distinguishing Between Overloaded Methods 239 3. 6.12.3 Return Types of Overloaded Methods 240 13. 6.13 (Optional) GUI and Graphics Case Study: Colors and Filled Shapes 240 14. 6.14 Wrap-Up 243 7. 7 Arrays and ArrayLists 257
The above is a preview of the first 20 pages. Register to read the complete e-book.

Recommended for You

Loading recommended books...
Failed to load, please try again later

Tip the Site

Scan the WeChat Pay or Alipay code to tip. No login required.

WeChat Pay
Alipay
Back to List