Hello Everyone,

This is my first post, so be gentle with me. I am working on an application and I have a need to store about 5 or 6, X and Y coordinate pairs. The values for X and Y are reasonably small integer values (less than 5000). Essentially all I need is an array of 5 or 6 "value containers" that hold one X and one Y value.

I tried to investigate "point" as an option, but if you have ever Googled the word "point" you can imagine that you get a LOT about Floating Point and how bad it is for the world, and not much on "point" as a vehicle for storing a couple of integers.

I would not be opposed to creating my own coordinate storage object, but I am not really that far along with Java yet and I would need some real "hand holding" to make that option work at this point in my Java career.

Thanks,
TahoeSands

Actually, I stumbled upon the perfect solution... The array X and Y coordinates I wanted to store were to eventually be used in "Rectangle" object.

(wait for it... and the light goes on)

Why not just use an array of Rectangle objects and pre-store the X and Y coordinate values in each Rectangle object? Doh!

Anyway, I would still be interested in seeing what solutions other people come up with.

Thanks,
TahoeSands

Just go ahead and use the Point class.

Edit: Ok, nevermind. Cross-posted as you posted the above. If you do need to work with other single points, there are convenience methods to test Point containment with various shapes, including Rectangle.

Edited 6 Years Ago by Ezzaral: n/a

Just go ahead and use the Point class.

Edit: Ok, nevermind. Cross-posted as you posted the above. If you do need to work with other single points, there are convenience methods to test Point containment with various shapes, including Rectangle.

Thanks Ezzara... I will continue to look at Point if I need to do this again in the future. Right now I am just anxious to finish this application I am developing. Its turning into a lot of fun.

quick heads up - if you're only using values <5000, perhaps use short not int?

quick heads up - if you're only using values <5000, perhaps use short not int?

Good point... A nanosecond saved is a nanosecond earned.

This question has already been answered. Start a new discussion instead.