On a really general level methods are a way to support modularity in computer software in general and in Object-Oriented programming (of which Java is an example) in particular. Methods are a way of grouping together code that performs a specific/singular function in a way that hides the details of how that function is implemented from the main body of the code and that promotes the reuse of that code. We'll talk about that aspect (the implementation hiding aspect) of methods tomorrow. If I fail to mention this issues please remind me, OK?
You'll need to know the details of how we actually include, code and call methods in our code.
Calling methods is easy. You've been doing it all along. Just put the method name along with any arguments in the brackets in your code and it will be executed under the appropriate circumstances.
For instance: System.Convert.toInt16("3457"); is a method call. So, for that matter, is System.out.println("Some kinda textin' goin' on");
For 10 points everybody, how do we know if a piece of code is a method call?
IT HAS BRACKETS
We also reviewed for loops.
We remember how a for loop works by
Interesting
Challenges
Excite
Innovators
where
I - Initialize the counter
C - Check the (exit) condition
E - Execute the body
I - Increment the counter
Be prepared to chant it tomorrow.
No comments:
Post a Comment