Method (static)
Function (method) definition.
Syntax
static returnType name(type p) { return ...; }Description
Return type, name, and parameters are written. Must be static if called from main.
Example
Loading editor…
Expected output
25
When to use?
Preventing code repetition.
Common mistakes
- ⚠️ void return type means 'returns nothing'.