副标题:无

作   者:

分类号:

ISBN:9787302083030

微信扫一扫,移动浏览光盘

简介

  《Java语言:计算机科学与程序设计》是由著名作者Walter Savitch编写的,主要介绍了Java 程序设计,对Java语言的主要特点和应用编程进行了全面讲述。《Java语言:计算机科学与程序设计》最显著的特点是,作者采用通俗易懂的方式,结合Java语方,介绍了各种基本编程技术,阐述了面向对象编程技术与计算机科学的各种概念。《Java语言:计算机科学与程序设计》每章后附本章小结,并提供了测试题和答案、编程项止练习,以帮助学生对所学知识的掌握,提高学生的实际编程能力。《Java语言:计算机科学与程序设计》配套光盘包含了范例程序代码和相应软件。   《Java语言:计算机科学与程序设计》可作为计算机科学及相关专业的Java程序设计教材,也是Java开发人员的很好参考书。

目录

chapter 1 introduction to computers and java 3

objectives 4

prerequisites 4

1.1 computer basics 4

hardware and memory 5

programs 7

programming languages and compilers 8

java byte-code 9

linking 12

1.2 designing programs 12

object-oriented programming 13

encapsulation 14

polymorphism 15

inheritance 16

if you know some other programming language 17

ngorithms 17

reusable components 18

testing and debugging 18

6otcha: coping with "gotchas" 19

6otcha: hidden errors 20

.1.3 a sip of java 20

history of the java language 20

applets 21

a first java application program 22

compiling a java program or class 28

running a java program 29

preview examples of applets (optional) 30

chapter summary 33

answers to self-test questions 34

programming projects 36


chapter 2 primitive types, strings, and console i/o 39

objectives 40

prerequisites 40

2.1 primitive types and expressions 40

variables 41

java identifiers 44

6otcha: java is case-sensitive 46

primitive types 46

assignment statements 47

specialized assignment operators 49

simple input and output 49

number constants 51

assignment compatibilities 52

type casting 53

java tip: type casting a character to an integer 55

programming tip: initialize variables 56

gotcha: imprecision in floating-point numbers 57

arithmetic operators 58

parentheses and precedence rules 60

case study: vending machine change 62

increment and decrement operators 66

more about the increment and decrement operators 67

2.2 the class string 68

string constants and variables 68

concatenation of strings 69

classes 70

string methods 71

string processing 75

escape characters 75

the unicode character set 77

2.3 keyboard and screen i/o 79

screen output 79

input using savitchin 82

more input methods 85

gotcha: readint and readdoub3 e 86

programming tip: echo input 87

2.4 documentation and style 88

programming tip: use meaningful names for variables 88

documentation and comments 89

indenting 90

named constants 92

chapter summary 95

answers to self-test questions 96

programming projects 99


chapter 3 flow of control 103

objectives 104

prerequisites 104

3.1 branching statements 104

the if-else statement 104

introduction to boolean expressions 108

gotcha: using==with strings 111

programming tip: alphabetical order 113

nested statements and compound statements 115

java tip: matching else and if 117

multibranch if-el se statements 118

programming example: assigning letter grades 119

the switch statement 122

gotcha: omitting a break statement 126

the conditional operator (optional) 126

3.2 java loop statements 128

while statements 129

java tip: a while loop can perform zero iterations 133

the do-while statement 133

programming example: bug infestation 137

gotcha: infinite loops 139

the for statement 141

the camma in for statements (optional)145

gotcha: extra semicolon in a loop statement 146

java tip: choosing a loop statement 148

the break statement in loops 148

gotcha: misuse of break statements 150

the exit method 150

3.3 programming with loops 152

the loop body 152

initializing statements 154

ending a loop 155

programming example: nested loops 156

programming tip: avoid declaring variables in a loop body 157

loop bugs 157

tracing variables 161

3.4 the type boolean 162

boolean expressions and boolean variables 163

programming tip: naming boolean variables 164

precedence rules 165

input and output of boolean values 168

case study: using a boolean variable to end a loop 168

chapter summary 172

answers to self-test questions 172

programming projects 177


chapter 4 defining classes and methods 181

objectives 182

prerequisites 182

4.1 class and method definitions 182

class files and separate compilation 184

instance variables 185

using methods 168

void method definitions 191

methods that return a value 193

java tip: use of return in void methods 196

the this parameter 198

local variables 200

blocks 202

gotcha:variables declared in a block 202

java tip: declaring variables in a for statement 203

parameters of a primitive type 203

gotcha: use of the terms parameter and argument 209

summary of class and method definition syntax 209

4.2 information hiding and encapsulation 210

information hiding 210

programming tip: parameter names are local to the method 211

precondition and postcondition comments 211

java tip: assertion checks 212

the publ i c and private modifiers 214

programming tip: instance variables should be private 217

programming example: a purchase class 221

encapsulation 225

automatic documentation with javadoc 228

uml class diagrams 228

4.3 objects and reference 230

variables of a class type and objects 230

gotcha: use of = and == with variables of a class type 235

java tip: define an equal s method for your classes 235

programming example: a species class 239

boolean-valued methods 242

class parameters 244

comparing class parameters and primitive-type parameters 247

chapter summary 251

answers to self-test questions 251

programming projects 257


chapter 5 more about objects and methods 261

objectives 262

prerequisites 262

5.1 programming with methods 263

methods calling methods 263

programming tip: make helping methods private 268

java tip: make the compiler happy 268

gotcha: null pointer exception 269

5.2 static methods and static variables 271

static methods 271

gotcha: invoking a nonstatic method within a static method 273

java tip: you can put a main in any class 275

static variables (optional) 277

the math class 279

integer, double, and other wrapper classes 282

5.3 designing methods 286

case study: formatting output 287

top-down design 291

testing methods 293

5.4 overloading 295

overloading basics 295

programming example: a pet class 298

gotcha: overloading and automatic type conversion 298

gotcha: you cannot overload on the basis of the returned type 303

programming example: a class for money 305

5.5 constructors 312

defining constructors 312

programming tip: you can use other methods in a constructor 320

gotcha: omitting the default constructor 321

gotcha: many wrapper classes have no default constructor 321

5.6 information hiding revisited 322

gotcha: privacy leaks 322

5.7 packages 326

packages and importing 326

package names and directodes 326

gotcha: not including the current directory in your class path 329

name clashes 330

chapter summary 331

answers to self-test questions 332

programming projects 337


chapter 6 arrays 341

objectives 342

prerequisites 342

6.1 array basics 343

creating and accessing arrays 343

array details 344

programming tip: use singular array names 348

the length instance variable 349

java tip: array indices start with zero 349

programming tip: use a for loop to step through an array 351

gotcha: array index out of bounds 351

initializing arrays 352

6.2 arrays in classes and methods 354

case study: sales report 354

indexed vadablas as method arguments 361

entire arrays as method arguments 364

arguments for the method mai n 364

gotcha: use of = and == with arrays 366

methods that return arrays 369

6.3 progrannning with arrays and classes 372

programming example: a specialized list class 373

partially filled arrays 380

searching an array 380

gotcha: returning an array instance variable 381

6.4 sorting arrays 383

selection sort 383

other sorting algorithms 388

6.5 multidimensional arrays 388

multidimensional-array basics 390

multidimensional-array parameters and returned values 392

implementation of multidimensional arrays 394

bagged arrays (opuonal) 397

programming example: employee time records 398

chapter summary 404

answers to self-test questions 405

programming projects 410


chapter 7 inheritance 415

objectives 416

prerequisites 416

7.1 inheritance basics 416

programming example: a person class 417

derived classes 418

overriding method definitions 421

overriding versus overloading 422

the final modifier 422

gotcha: use of private instance variables from the base class 423

programming tip: assume that your coworkers are malicious 424

gotcha: private methods are not inherited 424

uml inheritance diagrams 424

7.2 programming with inheritance 427

constructors in derived classes 427

the this method (opuonal)428

call to an overridden method 429

programming example: multilevel derived classes 430

a subtle point about overloading and overriding (optional) 435

java tip: you cannot use multiple supers 435

programming tip: an object can have more than one type 436

programming tip: "is a" and "has a" relations 439

the class object 440

case study: character graphics 442

abstract classes 452

interlaces (optional) 456

7.3 dynamic binding and polymorphism 458

dynamic binding 458

type checking and dynamic binding 460

dynamic binding with tostring 451

polymorphism 462

java tip: a better equal s method (optional)463

chapter summary 465

answers to self-test questions 466

programming projects 471


chapter 8 exception handling 475

objectives 476

prerequisites 476

8.1 basic exception handling 477

exceptions in java 477

predefined exception classes 489

arrayindexoutofboundsexception (alternative ordering) 490

8.2 defining exception classes 491

defining your own exception classes 491

java tip: preserve getmessage when you define exception classes 496

programming tip: when to define an exception class 497

8.3 using exception classes 502

declaring exceptions (passing the buck) 502

exceptions that de not need to be caught 506

the assertion error class (optional) 507

multiple throws and catches 507

java tip: catch the more specific exception first 510

programming tip: exception handling and information hiding 511

gotcha: overuse of exceptions 513

programming tip: when to throw an exception 513

gotcha: nested try-catch blocks 515

the finally block (optional)515

rethrowing an exception (optional) 516

case study' a line-oriented calculator 517

chapter summary 531

answers to self-test questions 532

programming projects 536


chapter 9 streams and file i/o 541

objectives 542

prerequisites 542

9.1 an overview of streams and file i/o 543

the concept of a stream 543

why use files for i/o? 543

differences between text files and binary files 543

9.2 text-file i/o 545

text-file output with printwriter 545

gotcha: a try block is a block 550

gotcha: overwriting a file 551

java tip: appending to a text file 551

java tip: use tostring for text-file output 553

text-file input with bufferedreader 556

programming example: reading a file name from the keyboard 560

java tip: using path names 562

the stringtokeni zer class 563

java tip: testing for the end of a text file 565

the classes filereader and fileoutputstream 567

unwrapping the class savi tchin 569

9.3 the file class 570

using the file class 570

9.4 basic binary-file i/o 573

output to binary files, using objectoutputstream 574

some details about writeutf (optional)579

reading input from a binary file, using objectinputstream 580

gotcha: using objectinputstream with a text file 584

gotcha: defining a method to open a stream 585

the eofexcepti on class 586

gotcha: forgetting to check for the end of a file 588

gotcha: checking for the end of a file in the wrong way 589

the classes fi i einputst ream and file0utputstream 589

programming example: processing a file of binary data 590

9.5 object i/o with object streams 594

binary i/0 of class objects 594

gotcha: exceptions, exceptions, exceptions 599

the serializable interface 599

gotcha: mixing class types in the same file 599

array objects in binary files 600

chapter summary 602

answers to self-test questions 603

programming projects 608


chapter 10 dynamic data structures 611

objectives 612

prerequisites 612

10.1 vectors 613

using vectors 613

programming tip: adding to a vector 619

gotcha: vector elements are of type object 620

comparing vectors and arrays 622

gotcha: using capacity instead of size 622

java tip: use trimtosize to save memory 624

gotcha: using the method clone 625

java tip: newer collection classes (optional)626

10.2 linked data structures 627

linked lists 627

gotcha: null pointer exception 636

gotcha: privacy leaks 637

inner classes 638

node inner classes 639

iterators 639

programming tip: internal and external iterators 652

exception handling with linked lists 652

variations on a linked list 656

other linked data structures 658

chapter summary 658

answers to self-test questions 659

programming projects 665


chapter 11 recursion 669

objectives 670

prerequisites 670

11.1 the basics of recursion 670

case study: digits to words 671

how recursion works 675

gotcha: infinite recursion 679

recursive versus iterative definitions 682

recursive methods that return a value 682

11.2 programming with recursion 687

programming tip: ask until the user gets it right 687

case study: binary search 689

programming tip: generalize the problem 693

programming example: merge sort--a recursive sorting method 697

chapter summary 702

answers to self-test questions 702

programming projects 705

chapter 12 window interfaces using swing 709

objectives 710

prerequisites 710

12.1 background 711

guis---graphical user interfaces 711

event-driven programming 711

12.2 basic swing details 713

gotcha: save all your work before running a swing program 714

programming example: a simple window 714

java tip: ending a swing program 719

gotcha: forgetting to program the close-window button 720

gotcha: forgetting to use getcontentpane 720

more about window listeners 720

size units for screen objects 722

more on setvisible 723

programming example: a better version of our first swing program 725

programming example: a window with color 728

some methods of the class jframe 732

layout managers 735

12.3 buttons and action listeners 742

programming example: adding buttons 742

buttons 744

action listeners and action events 746

gotcha: changing the parameter list for actionperformed 750

interfaces 751

java tip: code a gui's look and actions separately 752

the model-view--controller pattern 753

java tip: use the method setactioncommand 753

12.4 container classes 756

the jpanel class 756

the eontainer class 759

java tip: guide for creating simple window interfaces 762

12.5 text i/o for guis 764

text areas and text fields 764

programming example: labeling a text field 770

inputting and outputting numbers 772

programming example: a gui adding machine 775

catching a numberformatexcepti on 779

chapter summary 782

answers to self-test questions 783

programming projects 791


chapter 13 applets and html 795

objectives 796

prerequisites 796

13.1 applets 797

applet basics 797

running an applet 800

programming example: an adder applet 800

java tip: converting a swing application to an applet 803

adding icons to an applet 803

13.2 introduction to html 806

html basics 806

programming tip: a simple html-document outline 808

inserting hyperlinks 808

gotcha: not using your reload (refresh) button 812

chapter summary 886

answers to self-test questions 886

programming projects 890


appendix 1 keywords 892

appendix 2 precedence rules 893

appendix 3 unicode character set 894

appendix 4 savitchin 895

appendix 5 protected and package modifiers 908

appendix 6 the decimal format class 909

percent notation 909

scientific notation (e-notation) 911

appendix 7 the iterator interface 912

appendix 8 cloning 913

appendix 9 javadoc 916

commenting classes for use with javadoc 916

running javadoc 917

appendix 10 the joptionpane class 918

a sample program using joptionpane 918

multiline output windows 923

appendix 11 differences between c++ and java 924

primitive types 924

strings 924

flow of control 924

testing for equality 925

main method (function) and other methods 925

files and including files 925

class and method (function) definitions 925

no pointers in java 925

method (function) parameters 926

arrays 926

garbage collection 926

other comparisons 926

index 927


已确认勘误

次印刷

页码 勘误内容 提交人 修订印次

    • 名称
    • 类型
    • 大小

    光盘服务联系方式: 020-38250260    客服QQ:4006604884

    意见反馈

    14:15

    关闭

    云图客服:

    尊敬的用户,您好!您有任何提议或者建议都可以在此提出来,我们会谦虚地接受任何意见。

    或者您是想咨询:

    用户发送的提问,这种方式就需要有位在线客服来回答用户的问题,这种 就属于对话式的,问题是这种提问是否需要用户登录才能提问

    Video Player
    ×
    Audio Player
    ×
    pdf Player
    ×
    Current View

    看过该图书的还喜欢

    some pictures

    解忧杂货店

    东野圭吾 (作者), 李盈春 (译者)

    亲爱的云图用户,
    光盘内的文件都可以直接点击浏览哦

    无需下载,在线查阅资料!

    loading icon