Methods in Java — a practical guide to Java methods with clear examples you can reuse in real projects.
Java Tutorial Series (28/90). Prefer one article? Read the complete Java tutorial.
Short description
Methods reduce duplication. Use `static` methods for utilities that do not need object state.
Method example
public class MathUtils {
public static int add(int a, int b) {
return a + b;
}
public static void main(String[] args) {
System.out.println(add(2, 3));
}
}