Creating a Method
A method must be declared within a class. It is defined with the name of the method, followed by parentheses ( ) . |
|
System.out.println
,public
means the class, method, or member is available for use by all other classes.
myMethod
is the name of the method.
static
means that the method belongs to the MyClass
class and not an object of the MyClass
class.
void
means that this method does not have a return value.
( )
and a semicolon (;
).
The example uses myMethod to print a text (the action):
|
|