Invoke a Method : Method « Java Source And Data Type « SCJP






variable.methodName(argumentList)

public class MainClass {
  public static void main(String[] argv) {
    MyClass cls = new MyClass();

    cls.aMethod();
  }
}

class MyClass {
  public void aMethod() {
    System.out.println("aaa");
  }
}








1.23.Method
1.23.1.Methods are declared using the following syntax:
1.23.2.A method may have access modifier and the special modifiers.
1.23.3.Summary of Java keywords used with methods.
1.23.4.The return type of a method
1.23.5.The throws clause identifies all of the checked exception types that may be thrown
1.23.6.Declare super exception for method
1.23.7.Invoke a Method
1.23.8.It is illegal for a class to declare two methods with the same signature.
1.23.9.You can return null in a method with an object reference return type.
1.23.10.With a primitive return type, you can return any value or variable that can be implicitly converted to the declared return type.
1.23.11.You can return any value or variable that can be explicitly cast to the declared return type.
1.23.12.You must not return anything from a method with a void return type.