Calling methods:

Any java statement that looks like someWord() is a method.

This means find the segment of code that looks like someWord() { ... } and run the code in the { }. When execution is transferred to a method, we say that the method is CALLED. (Some languages require you to write "call someWord()")

Once the method is finished it RETURNS. This means that execution goes back to line of code that called the method.

You CANNOT put one method inside another method.

How to define a method:

____❶___ ___❷_____ methodName( ❸ ) { ...❹... }

A method can only ever return 1 thing. You cannot return two different pieces of information. If you have to do this, you must make an object that contains the information and return a single object.

How do you recognize a method?

  1. when a program calls a method it will look like pppppp().
    Examples:
    drawGraphics();
    System.out.print("Print me") ;
    c.setColor(Color.RED);
    myMethod(x,y,z);
    
  2. A method definition is NEVER inside another method. It is always just inside a class.

  3. Look for these three things to recognize method definitions. ALL METHODS HAVE THESE!