Example: marketing

The Java Tutorial - pearsoncmg.com

The java TutorialSixth i11/12/14 1:48 PM11/12/14 1:48 PMSince 1996, when Addison-Wesley published the first edition of The java programming Language by Ken Arnold and James Gosling, this series has been the place to go for complete, expert, and definitive information on java technology. The books in this series provide the detailed information developers need to build effective, robust, and portable applications and are an indispensable resource for anyone using the java for a complete list of available java Series Make sure to connect with us! ii11/12/14 1:48 PM11/12/14 1:48 PMThe java TutorialA Short Course on the BasicsSixth EditionRaymond GallardoScott HommelSowmya KannanJoni GordonSharon Biocca ZakhourUpper Saddle River, NJ Boston Indianapolis San FranciscoNew York Toronto Montreal London Munich Paris MadridCapetown Sydney Tokyo Singapore Mexico iii11/12/14 1:48 PM11/12/14 1:48 PMMany of the designations used by manufacturers and sellers to distinguish their products are claimed as trademar

vi Contents Questions 31 Exercises 32 Answers 32 Chapter 2 Object- Oriented Programming Concepts 33 What Is an Object? 34 What Is …

Tags:

  Programming, Tutorials, Java, Object, Oriented, The java tutorial, Oriented programming

Information

Domain:

Source:

Link to this page:

Please notify us if you found a problem with this document:

Other abuse

Advertisement

Transcription of The Java Tutorial - pearsoncmg.com

1 The java TutorialSixth i11/12/14 1:48 PM11/12/14 1:48 PMSince 1996, when Addison-Wesley published the first edition of The java programming Language by Ken Arnold and James Gosling, this series has been the place to go for complete, expert, and definitive information on java technology. The books in this series provide the detailed information developers need to build effective, robust, and portable applications and are an indispensable resource for anyone using the java for a complete list of available java Series Make sure to connect with us! ii11/12/14 1:48 PM11/12/14 1:48 PMThe java TutorialA Short Course on the BasicsSixth EditionRaymond GallardoScott HommelSowmya KannanJoni GordonSharon Biocca ZakhourUpper Saddle River, NJ Boston Indianapolis San FranciscoNew York Toronto Montreal London Munich Paris MadridCapetown Sydney Tokyo Singapore Mexico iii11/12/14 1:48 PM11/12/14 1:48 PMMany of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks.

2 Where those designations appear in this book, and the publisher was aware of a trademark claim, the designations have been printed with initial capital letters or in all authors 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 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 or (800) 382- government sales inquiries, please contact For questions about sales outside the , please contact Visit us on the Web: of Congress Cataloging- in- Publication DataGallardo, java Tutorial : a short course on the basics / Raymond Gallardo, Scott Hommel, Sowmya Kannan,Joni Gordon, Sharon Biocca Zakhour.

3 Sixth cmPrevious edition: The java Tutorial : a short course on the basics / Sharon Zakhour, Sowmya Kannan, Raymond Gallardo. 2013, which was originally based on The java Tutorial / by Mary 978- 0- 13- 403408- 9 (pbk. : alk. paper) ISBN 0- 13- 403408- 2 (pbk. : alk. paper)1. java (Computer program language) I. '3 dc23 2014035811 Copyright 2015, Oracle and/or its affi liates. All rights Oracle Parkway, Redwood Shores, CA 94065 Printed in the United States of America. 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.

4 To obtain permission to use material from this work, please submit a written request to Pearson Education, Inc., Permissions Department, One Lake Street, Upper Saddle River, New Jersey 07458, or you may fax your request to (201) 236- 13: 978- 0- 13- 403408- 9 ISBN- 10: 0- 13- 403408- 2 Text printed in the United States on recycled paper at Edwards Brothers Malloy in Ann Arbor, printing, December iv11/12/14 1:48 PM11/12/14 1:48 PMvPreface xxiiiAbout the Authors xxviiChapter 1 Getting Started 1 The java Technology Phenomenon 1 The java programming Language 2 The java Platform 2 What Can java Technology Do? 4 How Will java Technology Change My Life? 4 The Hello World! Application 5 Hello World! for the NetBeans IDE 6 Hello World!

5 For Microsoft Windows 15 Hello World! for Solaris and Linux 20A Closer Look at the Hello World! Application 23 Source Code Comments 24 The HelloWorldApp Class Defi nition 25 The main Method 25 Common Problems (and Their Solutions) 27 Compiler Problems 27 Runtime Problems 29 Questions and Exercises: Getting Started v11/12/14 1:48 PM11/12/14 1:48 PMvi ContentsQuestions 31 Exercises 32 Answers 32 Chapter 2 object - oriented programming Concepts 33 What Is an object ?

6 34 What Is a Class? 36 What Is Inheritance? 38 What Is an Interface? 39 What Is a Package? 40 Questions and Exercises: object - oriented programming Concepts 41 Questions 41 Exercises 41 Answers 41 Chapter 3 Language Basics 43 Variables 44 Naming 45 Primitive Data Types 46 Arrays 51 Summary of Variables 57 Questions

7 And Exercises: Variables 57 Operators 58 Assignment, Arithmetic, and Unary Operators 59 Equality, Relational, and Conditional Operators 62 Bitwise and Bit Shift Operators 65 Summary of Operators 66 Questions and Exercises: Operators 67 Expressions, Statements, and Blocks 68 Expressions 68 Statements 70 Blocks 71 Questions and Exercises: Expressions, Statements, and Blocks 71 Control Flow Statements 72 The if- then and if- then- else Statements 72 The switch Statement 74 The while and do- while Statements 79 The for Statement 80 Branching Statements 82 Summary of Control Flow Statements 85 Questions and Exercises: Control Flow Statements vi11/12/14 1:48 PM11/12/14 1.

8 48 PMContents viiChapter 4 Classes and Objects 87 Classes 88 Declaring Classes 89 Declaring Member Variables 90 Defi ning Methods 92 Providing Constructors for Your Classes 94 Passing Information to a Method or a Constructor 95 Objects 99 Creating Objects 100 Using Objects 104 More on Classes 107 Returning a Value from a Method 107 Using the this Keyword 109 Controlling Access to Members of a Class 110 Understanding Class Members 112 Initializing Fields 116 Summary of Creating and Using Classes and Objects 118 Questions and Exercises: Classes 119 Questions and Exercises: Objects 120 Nested Classes 121 Why Use Nested Classes?

9 122 Static Nested Classes 122 Inner Classes 123 Shadowing 123 Serialization 124 Inner Class Example 125 Local and Anonymous Classes 127 Modifi ers 127 Local Classes 127 Anonymous Classes 131 Lambda Expressions 136 When to Use Nested Classes, Local Classes, Anonymous Classes, and Lambda Expressions 155 Questions and Exercises: Nested Classes 156 Enum Types 157 Questions and Exercises: Enum Types 161 Chapter 5 Annotations 163 Annotations Basics 164 The Format of an Annotation vii11/12/14 1:48 PM11/12/14 1:48 PMviii ContentsWhere Annotations Can Be Used 165 Declaring an Annotation Type 165 Predefi ned Annotation Types 167 Annotation Types Used by the java Language 167 Annotations That Apply to Other Annotations 169 Type Annotations and Pluggable Type Systems 170 Repeating Annotations 171 Step 1: Declare a Repeatable Annotation Type 172 Step 2: Declare the Containing Annotation Type 172 Retrieving Annotations 173 Design Considerations 173 Questions and Exercises.

10 Annotations 173 Questions 173 Exercise 174 Answers 174 Chapter 6 Interfaces and Inheritance 175 Interfaces 175 Interfaces in java 176 Interfaces as APIs 177 Defi ning an Interface 177 Implementing an Interface 178 Using an Interface as a Type 180 Evolving Interfaces 181 Default Methods 182 Summary of Interfaces 192 Questions and Exercises: Interfaces 193 Inheritance 193 The java Platform Class Hierarchy 194An Example of Inheritance 195 What You Can Do in a Subclass 196 Private Members in a Superclass 196 Casting Objects 197 Multiple Inheritance of State, Implementation, and Type 198 Overriding and Hiding Methods 199 Polymorphism 203 Hiding Fields 206 Using the Keyword super 206 object as a Superclass 208 Writing Final Classes and Methods 212 Abstract Methods and Classes viii11/12/14 1:48 PM11/12/14 1:48 PMContents ixSummary of Inheritance 216 Questions and Exercises.


Related search queries