I'm developing a GUI program, where I have made classes, that cluster ActionListeners, by functionality. My question is regarding how the JVM handles jButtons, that has the same ActionListener added to them.
First; I am aware that the JVM can save memory, by letting two reference variables that point to an identical string (for instance), point to the same string object in the memory.
public class Example {
String str1 = "SomeString";
String str2 = "SomeString";
}
Now, my question is this: If I have, say, 5 jButtons. All buttons have the same ActionListener added to them. When the program is run, will they have 5 seperate, identical, instaces of the same class added to them? Or will the JVM do something similar (to the above mentioned) ?
- Thanks in advance :)