Is there a way to have an equivalent structure in Java 1.4?

Using a generic example of a Point (x, y) object, is there a way to get it as a structure in Java 1.4? The advantage would be that there would be no allocated memory allocation for the Point object, because the structure would be part of the containing object. But it still has member functions to access it.

I am 98% sure that the answer is not, but hopes that eternal life ...

what / why: In our code, we have 100,000 objects (about 12 - 14% of the total memory) that are int and logical. If it were a C # structure inside an object, it would reduce the number of objects. And ... we are looking to make it just int, where 0x40000000 is a boolean. But processing is much simpler if we have member methods for this int, and it is considered as a structure.

+5
source share
3 answers

There is no structural equivalent in Java now, although I believe that they were slated for future versions. Still looking at flies, maybe you are looking for http://en.wikipedia.org/wiki/Flyweight_pattern

+2
source

No, you should use Objectfor general "structures".

, int s, , .

int a = 9;
int b = 10;
long pair = (a << 32)|b;

32 a b long. :

a = (int)(pair >> 32);
b = (int)pair;
+1

tskuzzy answer: - int x int y Point , .

:

, , - , , Point. - , Point . ( ) , .

+1

All Articles