Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more
Download
Standard view
Full view
of .
Look up keyword
Like this
3Activity
0 of .
Results for:
No results containing your search query
P. 1
05 Slide

05 Slide

Ratings: (0)|Views: 27|Likes:
Published by devinliao

More info:

Published by: devinliao on Oct 31, 2008
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as PPT, PDF, TXT or read online from Scribd
See more
See less

08/27/2012

pdf

text

original

 
1
Liang, Introduction to Java Programming, Seventh Edition, (c) 2009 Pearson Education, Inc. All ri
Chapter 5 Methods
 
2
Liang, Introduction to Java Programming, Seventh Edition, (c) 2009 Pearson Education, Inc. All ri
Motivations
A method is a construct for grouping statements together to perform a function. Using a method, you can write thecode once for performing the function in a program andreuse it by many other programs. For example, often youneed to find the maximum between two numbers.Whenever you need this function, you would have to writethe following code:
int result;if (num1 > num2)result = num1;elseresult = num2; 
If you define this function for finding amaximum number between any twonumbers in a method, you don’t haveto repeatedly write the same code. Youneed to define it just once and reuse it by any other programs.
 
3
Liang, Introduction to Java Programming, Seventh Edition, (c) 2009 Pearson Education, Inc. All ri
Objectives
3
To define methods, invoke methods, and pass arguments to amethod (§5.2-5.5).
3
To develop reusable code that is modular, easy-to-read, easy-to-debug, and easy-to-maintain. (§5.6).
3
To use method overloading and understand ambiguousoverloading (§5.7).
3
To design and implement overloaded methods (§5.8).
3
To determine the scope of variables (§5.9).
3
To know how to use the methods in the Math class (§§5.10-5.11).
3
To learn the concept of method abstraction (§5.12).
3
To design and implement methods using stepwise refinement(§5.12).

Activity (3)

You've already reviewed this. Edit your review.
1 hundred reads
Dan liked this
venkata liked this

You're Reading a Free Preview

Download
scribd
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->