Starting Out With Java
From Control Structures through Objects
Starting Out With Java
From Control Structures through Objects
SEVENTH EDITION
Tony Gaddis
Haywood Community College
330 Hudson Street, NY NY 10013
Senior Vice President Courseware Portfolio Management: Marcia J. Horton
Director, Portfolio Management: Engineering, Computer Science & Global Editions: Julian Partridge
Portfolio Manager: Matt Goldstein
Portfolio Management Assistant: Meghan Jacoby
Managing Content Producer: Scott Disanno
Content Producer: Amanda Brands
Rights and Permissions Manager: Ben Ferrini
Manufacturing Buyer, Higher Ed, Lake Side Communications, Inc. (LSC): Maura Zaldivar-Garcia
Inventory Manager: Ann Lam
Product Marketing Manager: Yvonne Vannatta
Field Marketing Manager: Demetrius Hall
Marketing Assistant: Jon Bryant
Cover Designer: Joyce Wells
Cover Photo: Shutterstock/Tim UR
Printer/Binder: LSC Communications, Inc.
Full-Service Project Management: Sasibalan Chidambaram, SPi Global
Credits and acknowledgments borrowed from other sources and reproduced, with permission, in this textbook appear on appropriate page within text.
Copyright 2019, 2016, 2013 by Pearson Education, Inc., Hoboken, New Jersey 07030. All rights reserved. Manufactured in the United States of America. This publication is protected by copyright and permissions should 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 http://www.pearsoned.com/permissions/.
Many of the designations by manufacturers and seller to distinguish their products are claimed as trademarks. Where those designations appear in this book, and the publisher was aware of a trademark claim, the designations have been printed in initial caps or all caps.
Unless otherwise indicated herein, any third-party trademarks that may appear in this work are the property of their respective owners and any references to third-party trademarks, logos or other trade dress are for demonstrative or descriptive purposes only. Such references are not intended to imply any sponsorship, endorsement, authorization, or promotion of Pearsons products by the owners of such marks, or any relationship between the owner and Pearson Education, Inc. or its affiliates, authors, licensees or distributors.
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.
Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners.
Library of Congress Cataloging-in-Publication Data
Names: Gaddis, Tony, author.
Title: Starting out with Java. From control structures through objects / Tony Gaddis, Haywood Community College.
Description: Seventh edition. | NY, NY : Pearson Education, Inc., [2019] | Includes index.
Identifiers: LCCN 2017060354| ISBN 9780134802213 | ISBN 0134802217
Subjects: LCSH: Java (Computer program language) | Data structures (Computer science) | Object-oriented programming (Computer science)
Classification: LCC QA76.73.J38 G333 2019 | DDC 005.13/3--dc23 LC record
available at https://lccn.loc.gov/2017060354
1 18
ISBN 10: 0-13-480221-7
ISBN 13: 978-0-13-480221-3
Contents in Brief
Appendices AM Companion Website
Case Studies Companion Website
Chapters 1720 Companion Website
Contents
The following appendices, online chapters, and online case studies are available on the books online resource page at www.pearson.com/cs-resources.
Online Appendices:
Online Chapters:
Online Case Studies:
Location of videonotes in the text
Compiling and Running a Java Program, p. Using an IDE, p. Your First Java Program, p. |
Displaying Console Output, p. Declaring Variables, p. Simple Math Expressions, p. The Miles-per-Gallon Problem, p. |
The if Statement, p. The if-else Statement, p. The if-else-if Statement, p. The Time Calculator Problem, p. |
The while Loop, p. The Pennies for Pay Problem, p. |
Passing Arguments to a Method, p. Returning a Value from a Method, p. The Retail Price Calculator Problem, p. |
Writing Classes and Creating Objects, p. Initializing an Object with a Constructor, p. The Personal Information Class Problem, p. |
Accessing Array Elements in a Loop, p. Passing an Array to a Method, p. The Charge Account Validation Problem, p. |
Returning Objects from Methods, p. Aggregation, p. The BankAccount , Class Copy Constructor Problem, p. |
The Sentence Capitalizer Problem, p. |
Inheritance, p. Polymorphism, p. The Employee and Productionworker Classes Problem, p. |
Handling Exceptions, p. The Exception Project Problem, p. |
Next page