Nicht aus der Schweiz? Besuchen Sie lehmanns.de
Java, Global Edition - Walter Savitch

Java, Global Edition

Walter Savitch (Autor)

Media-Kombination
1024 Seiten
2014 | 7th edition
Pearson Education Limited
978-1-292-01833-1 (ISBN)
CHF 99,95 inkl. MwSt
zur Neuauflage
  • Titel erscheint in neuer Auflage
  • Artikel merken
Zu diesem Artikel existiert eine Nachauflage
Java: An Introduction to Problem Solving and Programming, 7e, is ideal for introductory Computer Science courses using Java, and other introductory programming courses in departments of Computer Science, Computer Engineering, CIS, MIS, IT, and Business.



Students are introduced to object-oriented programming and important concepts such as design, testing and debugging, programming style, interfaces inheritance, and exception handling. The Java coverage is a concise, accessible introduction that covers key language features. Objects are covered thoroughly and early in the text, with an emphasis on application programs over applets.



Teaching and Learning Experience

This program presents a better teaching and learning experience-for you and your students.



A Concise, Accessible Introduction to Java: Key Java language features are covered in an accessible manner that resonates with introductory programmers.
Tried-and-true Pedagogy: Numerous case studies, programming examples, and programming tips are used to help teach problem-solving and programming techniques.
Flexible Coverage that Fits your Course: Flexibility charts and optional graphics sections allow instructors to order chapters and sections based on their course needs.

Instructor and Student Resources that Enhance Learning: Resources are available to expand on the topics presented in the text.

Chapter 1 Introduction to Computers and Java 1

1.1 COMPUTER BASICS 2

Hardware and Memory 3

Programs 6

Programming Languages, Compilers, and Interpreters 7

Java Bytecode 9

Class Loader 11

1.2 A SIP OF JAVA 12

History of the Java Language 12

Applications and Applets 13

A First Java Application Program 14

Writing, Compiling, and Running a Java Program 19

1.3 PROGRAMMING BASICS 21

Object-Oriented Programming 21

Algorithms 25

Testing and Debugging 27

Software Reuse 28

1.4 GRAPHICS SUPPLEMENT 30

A Sample Graphics Applet 30

Size and Position of Figures 32

Drawing Ovals and Circles 34

Drawing Arcs 35

Running an Applet 37

Chapter 2 Basic Computation 47

2.1 VARIABLES AND EXPRESSIONS 48

Variables 49

Data Types 51

Java Identifiers 53

Assignment Statements 55

Simple Input 58

Simple Screen Output 60

Constants 60

Named Constants 62

Assignment Compatibilities 63

Type Casting 65

Arithmetic Operators 68

Parentheses and Precedence Rules 71

Specialized Assignment Operators 72

Case Study: Vending Machine Change 74

Increment and Decrement Operators 79

More About the Increment and Decrement Operators 80

2.2 THE CLASS STRING 81

String Constants and Variables 81

Concatenation of Strings 82

String Methods 83

String Processing 85

Escape Characters 88

The Unicode Character Set 89

2.3 KEYBOARD AND SCREEN I/O 91

Screen Output 91

Keyboard Input 94

Other Input Delimiters (Optional) 99

Formatted Output with printf (Optional) 101

2.4 DOCUMENTATION AND STYLE 103

Meaningful Variable Names 103

Comments 104

Indentation 107

Using Named Constants 107

2.5 GRAPHICS SUPPLEMENT 109

Style Rules Applied to a Graphics Applet 110

Creating a Java GUI Application with the JFrame Class 110

Introducing the Class JOptionPane 113

Reading Input as Other Numeric Types 123

Programming Example: Change-Making Program

with Windowing I/O 124

Chapter 3 Flow of Control: Branching 139

3.1 THE IF-ELSE STATEMENT 140

The Basic if-else Statement 141

Boolean Expressions 148

Comparing Strings 153

Nested if-else Statements 158

Multibranch if-else Statements 160

Programming Example: Assigning Letter Grades 162

Case Study: Body Mass Index 165

The Conditional Operator (Optional) 168

The exit Method 168

3.2 THE TYPE BOOLEAN 169

Boolean Variables 170

Precedence Rules 171

Input and Output of Boolean Values 174

3.3 THE SWITCH STATEMENT 176

Enumerations 182

3.4 GRAPHICS SUPPLEMENT 183

Specifying a Drawing Color 184

A Dialog Box for a Yes-or-No Question 187

Chapter 4 Flow of Control: Loops 199

4.1 JAVA LOOP STATEMENTS 200

The while Statement 201

The do-while Statement 204

Programming Example: Bug Infestation 209

Programming Example: Nested Loops 215

The for Statement 217

Declaring Variables within a for Statement 223

Using a Comma in a for Statement (Optional) 224

The for-each Statement 226

4.2 PROGRAMMING WITH LOOPS 226

The Loop Body 227

Initializing Statements 228

Controlling the Number of Loop Iterations 229

Case Study: Using a Boolean Variable to End a Loop 231

Programming Example: Spending Spree 233

The break Statement and continue Statement in Loops

(Optional) 236

Loop Bugs 239

Tracing Variables 241

Assertion Checks 243

4.3 GRAPHICS SUPPLEMENT 245

Programming Example: A Multiface Applet 245

The drawstring Method 250

Chapter 5 Defining Classes and Methods 267

5.1 CLASS AND METHOD DEFINITIONS 269

Class Files and Separate Compilation 271

Programming Example: Implementing a Dog Class 271

Instance Variables 272

Methods 275

Defining void Methods 278

Defining Methods That Return a Value 279

Programming Example: First Try at Implementing a Species Class 284

The Keyword this 288

Local Variables 290

Blocks 292

Parameters of a Primitive Type 293

5.2 INFORMATION HIDING AND ENCAPSULATION 299

Information Hiding 300

Precondition and Postcondition Comments 300

The public and private Modifiers 302

Programming Example: A Demonstration of Why Instance

Variables Should Be Private 305

Programming Example: Another Implementation of a Class

of Rectangles 306

Accessor Methods and Mutator Methods 308

Programming Example: A Purchase Class 312

Methods Calling Methods 316

Encapsulation 322

Automatic Documentation with javadoc 325

UML Class Diagrams 326

5.3 OBJECTS AND REFERENCES 327

Variables of a Class Type 328

Defining an equals Method for a Class 333

Programming Example: A Species Class 337

Boolean-Valued Methods 340

Case Study: Unit Testing 342

Parameters of a Class Type 344

Programming Example: Class-Type Parameters Versus

Primitive-Type Parameters 348

5.4 GRAPHICS SUPPLEMENT 352

The Graphics Class 352

Programming Example: Multiple Faces, but with a Helping Method 354

The Graphics2D Class and the Java2DTM API 358

The init Method 360

Adding Labels to an Applet 361

Chapter 6 More About Objects and Methods 383

6.1 CONSTRUCTORS 383

Defining Constructors 385

Calling Methods from Constructors 394

Calling a Constructor from Other Constructors (Optional) 397

6.2 STATIC VARIABLES AND STATIC METHODS 399

Static Variables 399

Static Methods 400

Dividing the Task of a main Method into Subtasks 407

Adding a main Method to a Class 408

The Math Class 410

Wrapper Classes 413

6.3 WRITING METHODS 419

Case Study: Formatting Output 419

Decomposition 425

Addressing Compiler Concerns 426

Testing Methods 428

6.4 OVERLOADING 430

Overloading Basics 430

Overloading and Automatic Type Conversion 433

Overloading and the Return Type 436

Programming Example: A Class for Money 438

6.5 INFORMATION HIDING REVISITED 445

Privacy Leaks 445

6.6 ENUMERATION AS A CLASS 449

6.7 PACKAGES 451

Packages and Importing 452

Package Names and Directories 453

Name Clashes 456

6.8 GRAPHICS SUPPLEMENT 457

Adding Buttons 457

Event-Driven Programming 459

Programming Buttons 459

Programming Example: A Complete Applet with Buttons 463

Adding Icons 466

Changing Visibility 468

Programming Example: An Example of Changing Visibility 468

Chapter 7 Arrays 491

7.1 ARRAY BASICS 493

Creating and Accessing Arrays 494

Array Details 497

The Instance Variable length 500

More About Array Indices 503

Initializing Arrays 506

7.2 ARRAYS IN CLASSES AND METHODS 508

Case Study: Sales Report 508

Indexed Variables as Method Arguments 516

Entire Arrays as Arguments to a Method 519

Arguments for the Method main 520

Array Assignment and Equality 521

Methods That Return Arrays 524

7.3 PROGRAMMING WITH ARRAYS AND CLASSES 528

Programming Example: A Specialized List Class 528

Partially Filled Arrays 536

7.4 SORTING AND SEARCHING ARRAYS 538

Selection Sort 538

Other Sorting Algorithms 542

Searching an Array 544

7.5 MULTIDIMENSIONAL ARRAYS 545

Multidimensional-Array Basics 546

Multidimensional-Array Parameters and Returned Values 549

Java's Representation of Multidimensional Arrays 552

Ragged Arrays (Optional) 553

Programming Example: Employee Time Records 555

7.6 GRAPHICS SUPPLEMENT 561

Text Areas and Text Fields 561

Programming Example: A Question-and-Answer Applet 561

The Classes JTextArea and JTextField 564

Drawing Polygons 566

Chapter 8 Inheritance, Polymorphism, and

Interfaces 589

8.1 INHERITANCE BASICS 590

Derived Classes 592

Overriding Method Definitions 596

Overriding Versus Overloading 597

The final Modifier 597

Private Instance Variables and Private Methods of a Base Class 598

UML Inheritance Diagrams 600

8.2 PROGRAMMING WITH INHERITANCE 603

Constructors in Derived Classes 603

The this Method-Again 605

Calling an Overridden Method 605

Programming Example: A Derived Class of a Derived Class 606

Another Way to Define the equals Methods in Undergraduate 611

Type Compatibility 611

The Class Object 616

A Better equals Method 618

8.3 POLYMORPHISM 620

Dynamic Binding and Inheritance 620

Dynamic Binding with toString 623

8.4 INTERFACES AND ABSTRACT CLASSES 625

Class Interfaces 625

Java Interfaces 626

Implementing an Interface 627

An Interface as a Type 629

Extending an Interface 632

Case Study: Character Graphics 633

Case Study: The Comparable Interface 646

Abstract Classes 650

8.5 GRAPHICS SUPPLEMENT 652

The Class JApplet 653

The Class JFrame 653

Window Events and Window Listeners 656

The ActionListener Interface 658

What to Do Next 658

Chapter 9 Exception Handling 671

9.1 BASIC EXCEPTION HANDLING 672

Exceptions in Java 673

Predefined Exception Classes 683

9.2 DEFINING yOUR OWN EXCEPTION CLASSES 685

9.3 MORE ABOUT EXCEPTION CLASSES 695

Declaring Exceptions (Passing the Buck) 695

Kinds of Exceptions 698

Errors 700

Multiple Throws and Catches 701

The finally Block 707

Rethrowing an Exception (Optional) 708

Case Study: A Line-Oriented Calculator 709

9.4 GRAPHICS SUPPLEMENT 721

Exceptions in GUIs 721

Programming Example: A JFrame GUI Using Exceptions 721

Chapter 10 Streams, File I/O, and Networking 739

10.1 AN OVERVIEW OF STREAMS AND FILE I/O 741

The Concept of a Stream 741

Why Use Files for I/O? 742

Text Files and Binary Files 742

10.2 TEXT-FILE I/O 744

Creating a Text File 744

Appending to a Text File 750

Reading from a Text File 752

10.3 TECHNIQUES FOR ANY FILE 755

The Class File 755

Programming Example: Reading a File Name

from the Keyboard 755

Using Path Names 757

Methods of the Class File 758

Defining a Method to Open a Stream 760

Case Study: Processing a Comma-Separated Values File 762

10.4 BASIC BINARY-FILE I/O 765

Creating a Binary File 765

Writing Primitive Values to a Binary File 767

Writing Strings to a Binary File 770

Some Details About writeUTF 771

Reading from a Binary File 772

The Class EOFException 778

Programming Example: Processing a File of Binary Data 780

10.5 BINARY-FILE I/O WITH OBJECTS AND ARRAYS 785

Binary-File I/O with Objects of a Class 785

Some Details of Serialization 789

Array Objects in Binary Files 790

10.6 NETWORK COMMUNICATION WITH STREAMS 793

10.7 GRAPHICS SUPPLEMENT 799

Programming Example: A JFrame GUI for Manipulating Files 799

Chapter 11 Recursion 821

11.1 THE BASICS OF RECURSION 822

Case Study: Digits to Words 826

How Recursion Works 830

Infinite Recursion 834

Recursive Methods Versus Iterative Methods 836

Recursive Methods That Return a Value 838

11.2 PROGRAMMING WITH RECURSION 842

Programming Example: Insisting That User Input Be Correct 842

Case Study: Binary Search 844

Programming Example: Merge Sort-A Recursive Sorting Method 852

Chapter 12 Dynamic Data Structures and Generics 869

12.1 ARRAY-BASED DATA STRUCTURES 871

The Class ArrayList 872

Creating an Instance of ArrayList 872

Using the Methods of ArrayList 874

Programming Example: A To-Do List 878

Parameterized Classes and Generic Data Types 881

12.2 THE JAVA COLLECTIONS FRAMEWORK 881

The Collection Interface 881

The Class HashSet 882

The Map Interface 884

The Class HashMap 884

12.3 LINKED DATA STRUCTURES 887

The Class LinkedList 887

Linked Lists 888

Implementing the Operations of a Linked List 891

A Privacy Leak 898

Inner Classes 899

Node Inner Classes 900

Iterators 900

The Java Iterator Interface 912

Exception Handling with Linked Lists 912

Variations on a Linked List 914

Other Linked Data Structures 916

12.4 GENERICS 917

The Basics 917

Programming Example: A Generic Linked List 920

APPENDICES

1 Getting Java 941

2 Running Applets 942

3 Protected and Package Modifiers 944

4 The DecimalFormat Class 945

Other Pattern Symbols 946

5 Javadoc 949

Commenting Classes for Use within javadoc 949

Running javadoc 950

6 Differences Between C++ and Java 952

Primitive Types 952

Strings 952

Flow of Control 952

Testing for Equality 953

main Method (Function) and Other Methods 953

Files and Including Files 953

Class and Method (Function) Definitions 954

No Pointer Types in Java 954

Method (Function) Parameters 954

Arrays 954

Garbage Collection 955

Other Comparisons 955

7 Unicode Character Codes 956

8 Introduction to Java 8 Functional Programming 957

INDEX 962



Verlagsort Harlow
Sprache englisch
Maße 193 x 234 mm
Gewicht 1586 g
Themenwelt Informatik Software Entwicklung Objektorientierung
ISBN-10 1-292-01833-X / 129201833X
ISBN-13 978-1-292-01833-1 / 9781292018331
Zustand Neuware
Haben Sie eine Frage zum Produkt?