Skip to content

Instantly share code, notes, and snippets.

✅ Inject it and use it:
...
@Autowired
TaskScheduler scheduler;
scheduler.schedule(
() -> System.out.println("Hello!"),
new CronTrigger("0 */5 * * * *") // every 5 min
);
Given a class:
class Report {
void print() {
...
}
}
❌ If we extend the class without @Override:
@mcasari
mcasari / gist:b0ee1d94046793ba20f02538ef916f48
Last active December 14, 2025 22:17
Java tip: Use interface default methods to handle backward compatibility (starting from Java 8)
✅ Suppose you have a Shape interface:
interface Shape {
double area();
}
✅ A typical implementation would be:
class Circle implements Shape {
private double radius;