Methods
static methods, parameters and return types, void.
Simple enough for a 5-year-old to understand
static method and return
methods to be called from main must be static. Return type, name, and parameters are written.
public class Main { static int square(int x) { return x * x; } public static void main(String[] args) { System.out.println(square(5)); }}🎯 Exercise & Practice
Test what you've learned — answer, write code, check instantly. (1 left)
🎯 Expected output: 17