The overview of reply from @Pagotti is right if done right. However, your classes are not static. If it is not static, it is instance. Do you know what happens when something is instance? It needs to save the reference to the original instance.
How can I prove that it is of instance? In the internal classes, you can do FragmentList.this
, which returns the reference to the object of FragmentList
who urged the class, for example, EquipeList
.
Internally, how does it work? All built-in class builders get an extra argument 1, the FragmentList.this
. Therefore, creating an object from an "instance" class imposes a more argument on the stack than a normal self-contained class constructor. It also has the question that each object will make a reference to more, so it will have one more field within each object.
What’s the real impact of this? Just by measuring, I think it’s almost nothing for normal applications. Know which games are not normal applications. A game needs to be optimized so that the user does not have the perception of framemiss. This means that you only have 16ms between two frames to process everything and provide a new screen (valid time for Android, remember on other platforms). But usually not with that one bit brushing you can give the required performance.
I believe that in this case the performance is not affected, but the organization of your project, this is not only for mobile applications, but for any type of project
– MarceloBoni
I understand, I also think logic should not affect. I think bad java, that it is necessary to type 15 lines for a simple action. How much in php the same action could be done with a single line. Any simple application we create fills up with classes. So that’s why I asked this question, so that I do not have problems in the future as many users using. Thank you for answering friend.
– Fernando VR
Don’t worry about performance in advance. This will lead you to avoid perfectly valid code patterns and write less readable code. Write the most correct and clean code you can. If performance issues arise, take steps to determine where the problem is. Rarely will it be in that kind of detail.
– Pablo Almeida
It is also necessary to take into consideration that java will create separate bytecodes files for each class, even if they are in a single file, maybe it affects only the compile time, but the performance after compiled I believe not.
– user28595
@The way he compiled it? If I’m not mistaken Java only accepts a public class (and non-public N) per file, and not N public classes (not speaking of Inner classes).
– Piovezan
@Piovezan I can’t tell you because the image is blocked for me. If it’s two public classes, you’re right, don’t compile anyway, but you can stack several classes in one file, not all within the public class, myself I’ve done it here several times in answers
– user28595
@Pabloalmeida thanks for answering. I’m just worrying now to avoid the most having to keep making changes afterwards. I’d rather go programming the right way. I’m putting everything in the same class exactly to avoid clutter with lots of files, but always have that fear of having to redo everything again. kkk,
– Fernando VR
@Articuno thanks for answering, I think that in the new version of android studio this already happens, give a look: https://image.ibb.co/gQWMYH/2018_02_21_13_54_54.jpg, I believe that’s what you’re saying. But if it doesn’t affect the performance ta great, the compilation for now is being fast.
– Fernando VR
@Piovezan I think you are right about several published classes in the same file, it even gives an error, but when you create one class inside the other, there works well. Take a look at this print where the error is and where it works: http://image.ibb.co/i5WwYH/2018_02_21_14_05_05.jpg
– Fernando VR