Theartandscienceofjava
An very good book from Stanford University. There is free video on internet which is based on this book.3.3 Operatorsand operands 65Combining integers and fioating- point numbers 66, Integerdivision and the remainder operator 67, Precedence 68Applying rules of precedence 70, Type conversion 73. 4 Assignment statements 73Shorthand assignment operators 76, The increment anddecrement operators 773.5 Boolean expressions 77Relational operators 78, logical operators 78, Shorl-circuitaluation 81, Flags 82, An example of boolecaiculation 823.6 Designing for change 83The importance of readability 83, Using named constants tosupport program maintenance 84, Using named constants tosupport program development 8.5Summary88Review questions 89Programming exercises 91龈@含罾@潍骂4.i Statement types in Java 96simple statements 6, Compound statements 98, Controlstatements 984.2 Control statements and problem solving 99Generalizing the Add2Integers program 100, The repeai-N-times pattern 101, The read-unlif-sentinel pattern 1024.3 The if statement 105Singie-line if statements 107, Muliline if statements 107,Theif-else statement 107, Cascading if statements 107, The ?tor 084.4 The switch statement 1104.5 The while statement 112Using the while loop 113, Infinite loops 114, Soivinghe loopand-a-haif probiem 11 54.6 The for statement 118The relationship between for and while 120, Using for withfloating- point data 120, Nested for statements 121, Simplegraphical animation 122Summary 126Review questions 126Programming exercises 1275e囊e兽5.1 A quick overview of methods 134Methods as mechanisms for hiding complexity 135, Methods asoois for programmers rather than users 135, Method calls asexpressions 1 36, Method calls as messages 1375.2 Writing your own methods 138The format of a method 1 39 The return statement 139Methods invoiving internal control structures 141, Methods thateturn nonnumeric values 142. Predicate methods 1445.3 Mechanics of the method-calling process 147Parameter passing 148, Calling methods from within othermethods 1525. 4 Decomposition 158Stepwise refinement 159, Specifying parameters 161Designing from the top down 163, Looking for commonfeatures 164, Completing the decomposition 1655.5 Algorithmic methods 166le"brute force"approach 166, Euclid's algorithm 168TheDefending the correctness of Euclid 's algorithm 168, Comparingthe efficiency of the two algorithms 170Summary 170Review questions 17Programming exercises 1726 Objects a rd G6.1 Using the RandomGenerator class 178Pseudorandom numbers 179, Using the RandomGeneratorciass 180. The role of the random number seed 1836.2 The javadoc documentation system 1856. 3 Defining your own classes 188The structure of a class definition 188, Coniroiling the visibilityentries 89. Encapsulation 1896. 4 Representing student information 190Declaring instance variables 190, Completing the classdefinition 191, Writing javadoc comments 194, Writing theconstructor 194, Gelters and seters 196, The toStringmethod 196, Defining named constanis in a class 197, Usingthe student class 1 986.5 rational numbers 1996.6 Extending existinges204Creating a class io represent filled rectangles 204, ruieserited constructors 208. Rules for inherited methods 209Summary 211Review questions 213Programming exercises 214②27. 1 The structure of memory 222representations 223, Mernory addresses 2ds ecimalBits, bytes, and words 222, Binary and hexade7.2 The allocation of memory to variables 226Memory diagrams for the Rational class 227, Garbagecollection 2327.3 Primitive types versus objects 232Parameter passing 234, Wrapper classes 236, Boxing andunboxing 2387.4 Linking objects together 240Message passing in linked siructures: The beacons ofGondor 240, The interna representation of linkedstructures 243Summary 244Review questions 245Programming exercises 2478r$了需e8. 1 The principle of enumeration 250Representing enumerated types inside the machine 25!Representing enumerated types as integers 252, Defining newenumerated hypes 2538.2 Characters 254The daia type char 254, The ASCl! and Unicode codingsystems 254, Character constants 257, Important properties cthe Unicode representation 257, Special characters 258class 261, Control statements involving characters 20u erCharacter arithmetic 259 Useful methods in the characte8. 3 Strings as an abstract idea 263Holistic and reductionist views of strings 264, The notion of anabstrac! type 2648. 4 Using the methods in the String class 265a string 267, Concatenation 267, Extracting parts ofa/SfromDetermining the length of a string 265, selecting charactersiring 269, Comparing one string with another 270, Searchingwiihin a string 271, Case conversion 2738.5 a case study in string pirocessing273Applying top-down design 273, Implementingtranslateline 275, Taking spaces and punctuation intoaccount 276, The StringTokenizer class 278, Completingthe implementation 280Summary 284Review questions 284Programming exercises 2869 NecE@rien的 ed Graphis⑨墨The acm graphics model 299.2 Structure of the acm graphics package 297the Canvas class 297 Further details about the colorclass 300, The GPoint, GDimension, and REctangleclasses 301, The GMath class 302, The Gobject class and itssubclasses 3039. 3 Using the shape classes 306The Glabel class 306. The GRect class and its subclassesGRoundRect and G3DRect)311, The GOval class 31 1,TheGLine class 3 12. The GArc class 313, The GImage class 316The Polygon class 329.4 Creating compound objects 328Anple COmpound example 328, The Compound coordinatesystem 331, Object decomposition using COmpound 331Nesting COmpound objectsSummary 338Review questions 339Programming exercises 340冒@區vee@『朗s10.1 The java event model 35010.2 A simple event-driven program 35110.3 Responding to mouse events 354The mouselistener and mouseMotionlistener interfacesOverriding listener methods 355, A line-drawing program256Dragging objects on the canvas 35810.4 Responding to keyboard events 36010.5 Creating a simple GUl 36210.6 The Swing interactor hierarchy 365classes 369, The JSlider and Jlabel classes 371, he toThe JButton class 365, The JToggleButton class367,ThJCheckBox class 368. The rAdiobUtton ond ButtonGroJComboBox class 372. The textField, IntField andDoubleField classes 37410.7 Managing component layout 380BorderLayout manager 383, The FlowLayout manager 385The Java windowing hierarchy 3 80, layout managers 382, ThThe GridLayout manager 386, The inadequacy of the standardlayout managers 38710.8 Using the tablelayout class 388Comparing GridLayout and Tablelayout 388, UsingTablelayout to create a lemperature converter 389, SpecifyingXIVconstraints 390, Using rableLayout to create a simplecalculator 390Summary 399Review questions 40Programming exercises 402目 Arrays and Arreylisis11.1 Introduction to arrays 410Array declaration 4.11, Array selection 412, An example of aabjects 415, Using arrays in graphical programs 41, ys oisimple array 413, Changing the index range 414, Arraydigression on the + and -operators 41711.2 Internal representation of arrays 41911.3 Passing arrays as parameters 4211.4 Using arrays for tabulation 42711.5 Initialization of arrays 42811.6 Multidimensional arrays 430Passing muitidimensional arrays to methods 431, Initializingmultidimensional arrays 4321.7 Image processing 432Representation of images 433, Using the GImage class tomanipulate images 433, Bit manipulation 434, Using bi!operations to isolate components of a pixel 437, Creating agrayscale image 438, Smoothing an image throughaveraging 439, Hiding complexity 43911. 8 The Arraylist class 442Summary 448Review questions 449Programming exercises 450I2 Searching and SoFting4冒12.1 Searching 462Searching in an integer array 462 Searching a table 463,Binary search 466, The relative efficiency of the seardalgorithms 46812.2 Sorting 470Sorting an integer array 470, The selection sort algorithm 47TEvaluating the efficiency of selection sort 473, Measuring therunning time et a program 475, Analyinp78the selecTion sortalgorithm 476, The radix sort aigorithm12. 3 Assessing algorithmic efficiency 481Big-O notation 481, Standard simplifications of big-O 4.82, Thecomputational complexity of selection sort 482, Predictingcomputational complexity from code structure 483, Worst-caseversus average-case complexity 48512. 4 Using data files 486The concept of a file 486, Reading text files in java 488Exception handling 490, A program to reverse a file 492Selecting files interactively 492, Using the Scanner ciass 495Using files for output 497Suumnory498Review questions 499Programming exercises 500i3 Collection classes13. 1 The Arraylist class revisited 508The power of dynamic allocation 509, Separating behavior fromrepresentation 5E13. 2 The HashMap class 512implementation strategies 514, Achieving O-ADossibieA simple example of a map 513, Exploringance 516. The ideashing 517, Hashcodes 517, Duplication of hash codes 518, A simpleimplementation of a map class 518, implementing hashcodemethods 522, Adjusting the number of buckets 52313.3 The Java Collections Framework 524representation28, Iterators 529, The arraysCollections method libraries 53213. 4 Principles of object-oriented design 534The importance of a unifying theme 536, Simplicity and therinciple o536, Meeting the needs of yourlients 538, The advantages of flexibility 538, The value ostability 539Summary 539Review questions 540Programming exercises 541i4 Looking Ahead5超14.1 Recursion 546a simple illustration of recursion 547, The Factorialfunction 548, The recursive leap of faith 552, The recursiveparadigm 553, Graphical recursion 554, Thinkingrecursively 55814.2 Concurrency 558Processes and threads 558, A simple example ofconcurrency 559XVI4.3 Using the network 56214.4 Programming patterns 562The model/view/ controller patern 563, An illustrative exampleGraphing spreadsheet data 564Summary 570Review questions 570Programming exercises 571indexCHAPTERIntroduction/The Analytical Engine offers)a new, a vast, and a poweryfitllanguage. for the purposes of mankind-Augusta Ada Byron, Lady lovelace, 1843的技Augusta Ada Byron, lady Lovelace(1815-1852)Augusta Ada Byron, the daughter of English poet Lord Byron, was encouraged topursue her interests in science and mathematics at a time when few women wereallowed to study those subjects. At the age of 17, Ada met Charles Babbage,aprominent English scientist who devoted his life to designing machines forcarrying out mathematical computations -machines whose construction he wasnever able to complete. Ada was firmly convinced of the potential of BabbagesAnalytical Engine and wrote extensive notes on its design, along with severalcomplex mathematical programs that have led many people to characterize her asthe first programmer. In 1980, the U.S. Department of Defense named theprogramming language Ada in her honor
下载地址
用户评论
很好,很清晰。