no Point2D.setLocation(x,y)?

Jim Graham james.graham at oracle.com
Thu Jul 30 01:04:42 UTC 2015


Would adding final to the field declarations also aid in the 
inline-ability of the getters?

			...jim

On 7/29/15 5:32 PM, Kevin Rushforth wrote:
> Point2D is immutable by design, so there are no setters. And yes, the
> private variables for x and y could be made final, but since that's not
> API it would just add a bit of clarity to the implementation.
>
> -- Kevin
>
>
> Sam Howman wrote:
>> Hi,
>>
>> I'm wondering why there such a method or even setX/setY. I understand
>> that
>> some classes prevent such manipulation of their initial values
>> although it
>> seems like moving a point would be a very common thing to want to do. The
>> alternative would be to create a new Point2D whenever you would have
>> otherwise used "setLocation" (or similiar). This would probably be ok but
>> when there are say 100K points or more the impact on memory is
>> significant.
>> So is there a good reason why they can not be changed once created?
>> And if
>> this really is the intention should x and y be declared as "final"?
>>
>> Regards,
>> Sam.


More information about the openjfx-dev mailing list