AP® Computer Science A glossary

Method

Course: AP® Computer Science A Shows up in: Unit 1: Using Objects and Methods

A named block of code that only runs when it is called.

Appears in the course and exam description (CED): 1.9.A.11.7.A.2

A method groups statements under a name. Calling it runs those statements, then control returns to the point right after the call. Methods can be class methods or instance methods.

public static void greet()
{
    System.out.println("Hi");
}

// in main
greet();
greet();

Output:

Hi
Hi
Learn it properly, with a checkpoint 1.9 Method Signatures

Related terms

Was this page helpful?

No names are ever shown, and every public comment is checked by us first. Please do not include personal details. To get a reply, email [email protected].

↑ Top

Enlarged view of the selected figure