Assume that I have a Java class (which we will call Example: Now this code I know that in the implementation B, for the method Question: Is there any difference in performance between the two implementations? Is faster than B? About the cost of memory, is there a demand for more memory than B? I think it does, but a bit more (an additional reference to each additional area in B. Each reference is an int size, is not it?) Thanks! 1 In addition to what Russell said, there is a violation of the two areas where it has defined area. You give a very trivial example, but imagine that there is a need to change the definition of any of those static areas. With the second implementation you will need to update the code twice - remember that you have two definitions of the same area. that class ) field (None of them are fields) and assume that I use a lot of time in all those areas, in many ways from each class, which we will call on
ThisClass Keeping in mind where both memory usage and performance are important,
ThatClass , which is the
this class in the field as
ThisClass ?
thatclass public class {public static final fu field 1 = new fu (); Public stable final fu field 2 = new fu (); Public stable final fu field 3 = new foo (); } // implementing a public class ThisClass {public (ThisClass (for (int i = 0; i
// implement this other implementation to the public class thisClass {Private Final Foo myField1; Private Final Foo MyFilled 2; Personal Files La Foo MyField 3; Public This Class () {myField1 = ThatClass.field1; MyField2 = ThatClass.field2; for MyField3 = ThatClass.field3; (IntiI = 0; I
bar pass three areas as arguments It would not be necessary, but imagine this for a discussion that there was a need.
No comments:
Post a Comment