September 2016
Beginner to intermediate
1089 pages
23h 8m
English
So what exactly are Java methods? A method is a collection of variables, expressions, and control flow statements. We have already been using lots of methods; we just haven't looked inside any yet.
Learning about Java methods will be the last topic for this chapter before we get practical and use what we have learned to enhance our math game.
The first part of a method that we write is called the signature. Here is a made-up example of a signature:
public boolean shootLazers(int number, string type)
Add an opening and closing pair of curly braces with some code that the method performs, and we have a complete method, or a definition. Here is a made-up but syntactically correct method:
private void setCoordinates(int ...
Read now
Unlock full access