Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.help > #2448

Re: Array of a Class Type that contains an array where the sizes of the array are not known at compile time.

From Eric Sosman <esosman@comcast-dot-net.invalid>
Newsgroups comp.lang.java.help
Subject Re: Array of a Class Type that contains an array where the sizes of the array are not known at compile time.
Date 2013-01-14 16:59 -0500
Organization A noiseless patient Spider
Message-ID <kd1v4d$u9n$1@dont-email.me> (permalink)
References <f2b43fa0-1da2-4dc4-981b-bb756186050b@googlegroups.com> <atKIs.36232$TH3.9358@newsfe12.iad> <fcf46194-fde7-4096-b2d1-490586ccb83a@googlegroups.com>

Show all headers | View raw


On 1/14/2013 4:36 PM, GCRhoads@volcanomail.com wrote:
>[...]
> Sure I can write.
>
> conf = new Config[ m ]
> for (int i=0; i < m; i++)
>     conf[i] = new Config( n );
>
> but I need to ensure that the memory returned by the successive calls to
> "new Config( n )" occupy contiguous memory locations.  I know how to do this in
> C or C++ but the solution uses pointer arithmetic which Java doesn't have.
>
> How can I do this in Java?

     You cannot.

     To begin with, the memory location of a particular object is
not necessarily constant during the object's lifetime.  The garbage
collector may move it from place to place, may even move it more
than once.  So even if you somehow managed to get two instances to
occupy adjacent chunks of memory it wouldn't last: They'd wander.

     Second, if two objects' memory areas happen to be adjacent at
some time, how could you detect it?  Or, how could you detect that
they are not adjacent?  Can you think of *any* Java code that would
behave differently if objects X and Y were or were not adjacent?
If not, why do you care where the objects happen to reside?

-- 
Eric Sosman
esosman@comcast-dot-net.invalid

Back to comp.lang.java.help | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Array of a Class Type that contains an array where the sizes of the array are not known at compile time. GCRhoads@volcanomail.com - 2013-01-13 17:38 -0800
  Re: Array of a Class Type that contains an array where the sizes of the array are not known at compile time. Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2013-01-13 18:56 -0800
    Re: Array of a Class Type that contains an array where the sizes of the array are not known at compile time. GCRhoads@volcanomail.com - 2013-01-14 13:36 -0800
      Re: Array of a Class Type that contains an array where the sizes of the array are not known at compile time. Eric Sosman <esosman@comcast-dot-net.invalid> - 2013-01-14 16:59 -0500
        Re: Array of a Class Type that contains an array where the sizes of the array are not known at compile time. GCRhoads@volcanomail.com - 2013-01-14 20:00 -0800
          Re: Array of a Class Type that contains an array where the sizes of the array are not known at compile time. GCRhoads@volcanomail.com - 2013-01-14 20:04 -0800
            Re: Array of a Class Type that contains an array where the sizes of the array are not known at compile time. Patricia Shanahan <pats@acm.org> - 2013-01-14 23:44 -0800
            Re: Array of a Class Type that contains an array where the sizes of the array are not known at compile time. Eric Sosman <esosman@comcast-dot-net.invalid> - 2013-01-15 09:07 -0500
          Re: Array of a Class Type that contains an array where the sizes of the array are not known at compile time. Jukka Lahtinen <jtfjdehf@hotmail.com.invalid> - 2013-01-15 09:06 +0200
          Re: Array of a Class Type that contains an array where the sizes of the array are not known at compile time. Eric Sosman <esosman@comcast-dot-net.invalid> - 2013-01-15 08:32 -0500
          Re: Array of a Class Type that contains an array where the sizes of the array are not known at compile time. Lew <lewbloch@gmail.com> - 2013-01-15 11:19 -0800
          Re: Array of a Class Type that contains an array where the sizes of the array are not known at compile time. Joshua Cranmer <Pidgeot18@verizon.invalid> - 2013-01-15 13:52 -0600
      Re: Array of a Class Type that contains an array where the sizes of the array are not known at compile time. Roedy Green <see_website@mindprod.com.invalid> - 2013-01-15 20:56 -0800
  Re: Array of a Class Type that contains an array where the sizes of the array are not known at compile time. markspace <markspace@nospam.nospam> - 2013-01-13 19:01 -0800
    Re: Array of a Class Type that contains an array where the sizes of the array are not known at compile time. Lew <lewbloch@gmail.com> - 2013-01-13 21:39 -0800

csiph-web