If you wish to link 4 classes with each other using 4 different Java codes here at code playground, then its not possible. Each code is independent of every other. You need to have all of them in the same code.
It's a Java feature where one class can have multiple inner classes. You can even make the classes anonymous. Find a very nice modern java programming book you will learn it. I haven't take Sololearn Java course, so I wouldn't know if there is inner classes lesson.