Non-static nested classes are needed for those cases when a class is created as part of another class (so that many classes with similar names do not create, aka carWheel, bicycleWheel, etc.) (aesthetics) or when a class many uses variables of the outer class (those part). More than they are from ordinary classes are no different (except for the ban on the creation of static variables and static methods).
Based on these data, the question emerges - what do I lose when using composition and aggregation:

class Bicycle{ Wheel wheel; Bicycle(int ΡΡ‚Π΅ΠΏΠ΅Π½ΡŒΠΠ°ΠΊΠ°Ρ‡ΠΊΠΈΠšΠΎΠ»Π΅Ρ/*ΠΈ Π΄Ρ€ΡƒΠ³ΠΈΠ΅ ΠΏΠ΅Ρ€Π΅ΠΌΠ΅Π½Π½Ρ‹Π΅*/){ wheel = new Wheel(ΡΡ‚Π΅ΠΏΠ΅Π½ΡŒΠΠ°ΠΊΠ°Ρ‡ΠΊΠΈΠšΠΎΠ»Π΅Ρ); /*ΠΈ Π΄Ρ€ΡƒΠ³ΠΈΠ΅ ΠΏΠ΅Ρ€Π΅ΠΌΠ΅Π½Π½Ρ‹Π΅*/ } Bicycle(/*Π΄Ρ€ΡƒΠ³ΠΈΠ΅ ΠΏΠ΅Ρ€Π΅ΠΌΠ΅Π½Π½Ρ‹Π΅*/){ wheel = new Wheel(); /*Π΄Ρ€ΡƒΠ³ΠΈΠ΅ ΠΏΠ΅Ρ€Π΅ΠΌΠ΅Π½Π½Ρ‹Π΅*/ } class Wheel{ int ΡΡ‚Π΅ΠΏΠ΅Π½ΡŒΠΠ°ΠΊΠ°Ρ‡ΠΊΠΈΠšΠΎΠ»Π΅Ρ; Wheel(int ΡΡ‚Π΅ΠΏΠ΅Π½ΡŒΠΠ°ΠΊΠ°Ρ‡ΠΊΠΈΠšΠΎΠ»Π΅Ρ){ this.ΡΡ‚Π΅ΠΏΠ΅Π½ΡŒΠΠ°ΠΊΠ°Ρ‡ΠΊΠΈΠšΠΎΠ»Π΅Ρ = ΡΡ‚Π΅ΠΏΠ΅Π½ΡŒΠΠ°ΠΊΠ°Ρ‡ΠΊΠΈΠšΠΎΠ»Π΅Ρ; } Wheel(){ ΡΡ‚Π΅ΠΏΠ΅Π½ΡŒΠΠ°ΠΊΠ°Ρ‡ΠΊΠΈΠšΠΎΠ»Π΅Ρ=0; } void weGotDamage(){ toStopEveryThing();//ΠΌΡ‹ ΠΈΠΌΠ΅Π΅ΠΌ доступ ΠΊ ΠΏΠ΅Ρ€Π΅ΠΌΠ΅Π½Π½Ρ‹ΠΌ ΠΈ ΠΌΠ΅Ρ‚ΠΎΠ΄Π°ΠΌ внСшнСго класса! } } void toStopEveryThing(){ //code } public static void main(String[] args){ Bicycle bicycle = new Bicycle(500); bicycle.wheel.weGotDamage();//Π²Ρ‹Π·Ρ‹Π²Π°Π΅ΠΌ ΠΌΠ΅Ρ‚ΠΎΠ΄ ΠΎΠ±ΡŠΠ΅ΠΊΡ‚Π° wheel toStopEveryThing(); } } 

Compared to this implementation:

 class Bicycle2{ Bicycle2(){} class Wheel{ int ΡΡ‚Π΅ΠΏΠ΅Π½ΡŒΠΠ°ΠΊΠ°Ρ‡ΠΊΠΈΠšΠΎΠ»Π΅Ρ; Wheel(int ΡΡ‚Π΅ΠΏΠ΅Π½ΡŒΠΠ°ΠΊΠ°Ρ‡ΠΊΠΈΠšΠΎΠ»Π΅Ρ){ this.ΡΡ‚Π΅ΠΏΠ΅Π½ΡŒΠΠ°ΠΊΠ°Ρ‡ΠΊΠΈΠšΠΎΠ»Π΅Ρ = ΡΡ‚Π΅ΠΏΠ΅Π½ΡŒΠΠ°ΠΊΠ°Ρ‡ΠΊΠΈΠšΠΎΠ»Π΅Ρ; } Wheel(){ ΡΡ‚Π΅ΠΏΠ΅Π½ΡŒΠΠ°ΠΊΠ°Ρ‡ΠΊΠΈΠšΠΎΠ»Π΅Ρ=0; } void weGotDamage(){ toStopEveryThing();//ΠΌΡ‹ ΠΈΠΌΠ΅Π΅ΠΌ доступ ΠΊ ΠΏΠ΅Ρ€Π΅ΠΌΠ΅Π½Π½Ρ‹ΠΌ ΠΈ ΠΌΠ΅Ρ‚ΠΎΠ΄Π°ΠΌ внСшнСго класса! } } void toStopEveryThing(){ //code } public static void main(String[] args){ Bicycle2 bicycle = new Bicycle2(); Bicycle2.Wheel wheel = bicycle.new Wheel(500); wheel.weGotDamage();//Оно свяТСтся с bicycle ΠΈ Π²Ρ‹Π·ΠΎΠ²Π΅Ρ‚ ΠΌΠ΅Ρ‚ΠΎΠ΄ toStopEveryThing(); } } 
  • 2
    Possible duplicate question: Internal and nested classes - Grundy
  • @Grundy What this means: "Internal member classes are not associated with the external class itself, but with its instance.". From a technical point of view? If so, why create them separately, if we can use composition and aggregation? After all, it will be more logical. Those features I know (and wrote to complete the picture), but this question is interesting to me. - Miron
  • This is just a brief overview of the possibilities. And I'm talking about design (using composition and aggregation). This is not a duplicate question - Miron
  • one
    The rephrased question is incomprehensible. And you cannot give an unequivocal answer to it, some will say that it is necessary only to use them, others will say that it is necessary not only to use them, others will say that aggregation and composition should not be used at all - Grundy
  • one
    @Miron, this is exactly what is written in the help: How to ask a good question? - Grundy

0