Avatar ·

What is the difference between an inner class and a static nested class in Java?

Hello colleagues! I've just started learning Java and came across the topic of nested classes. I'm reading different sources, but I can't grasp the clear difference between an inner class and a static nested class. Both seem to be declared inside another class, but they behave differently. For example, I have this code: ```java public class Outer { private String message = "Hello from Outer"; class Inner { public void print() { System.out.println(message); } } static class StaticNested { public void print() { // Here I cannot directly access message // System.out.println(message); // Compilation error } } } ``` Questions: 1. Why can Inner access