tailieunhanh - Lecture Java™ How to Program (8/e) - Chapter 6: Methods: A deeper look

After completing this chapter, students will be able to: How static methods and fields are associated with an entire class rather than specific instances of the class, to use common Math methods available in the Java API, to understand the mechanisms for passing information between methods, how the method call/return mechanism is supported by the method call stack and activation records,. | Java™ How to Program, 8/e (C) 2010 Pearson Education, Inc. All rights reserved. (C) 2010 Pearson Education, Inc. All rights reserved. (C) 2010 Pearson Education, Inc. All rights reserved. Best way to develop and maintain a large program is to construct it from small, simple pieces, or modules. divide and conquer. Topics in this chapter static methods Declare a method with more than one parameter Method-call stack Simulation techniques with random-number generation. How to declare values that cannot change (., constants) in your programs. Method overloading. (C) 2010 Pearson Education, Inc. All rights reserved. Java programs combine new methods and classes that you write with predefined methods and classes available in the Java Application Programming Interface and in other class libraries. Related classes are typically grouped into packages so that they can be imported into programs and reused. You’ll learn how to group your own classes into packages in Chapter 8. . | Java™ How to Program, 8/e (C) 2010 Pearson Education, Inc. All rights reserved. (C) 2010 Pearson Education, Inc. All rights reserved. (C) 2010 Pearson Education, Inc. All rights reserved. Best way to develop and maintain a large program is to construct it from small, simple pieces, or modules. divide and conquer. Topics in this chapter static methods Declare a method with more than one parameter Method-call stack Simulation techniques with random-number generation. How to declare values that cannot change (., constants) in your programs. Method overloading. (C) 2010 Pearson Education, Inc. All rights reserved. Java programs combine new methods and classes that you write with predefined methods and classes available in the Java Application Programming Interface and in other class libraries. Related classes are typically grouped into packages so that they can be imported into programs and reused. You’ll learn how to group your own classes into packages in Chapter 8. (C) 2010 Pearson Education, Inc. All rights reserved. (C) 2010 Pearson Education, Inc. All rights reserved. Methods help you modularize a program by separating its tasks into self-contained units. Statements in method bodies Written only once Hidden from other methods Can be reused from several locations in a program Divide-and-conquer approach Constructing programs from small, simple pieces Software reusability Use existing methods as building blocks to create new pro-grams. Dividing a program into meaningful methods makes the program easier to debug and maintain. (C) 2010 Pearson Education, Inc. All rights reserved. (C) 2010 Pearson Education, Inc. All rights reserved. (C) 2010 Pearson Education, Inc. All rights reserved. (C) 2010 Pearson Education, Inc. All rights reserved. Hierarchical form of management (Fig. ). A boss (the caller) asks a worker (the called method) to perform a task and report back (return) the results after completing the task. The boss