Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #10136
| From | Lew <lewbloch@gmail.com> |
|---|---|
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: Size of an arraylist in bytes |
| Date | 2011-11-20 20:28 -0800 |
| Organization | http://groups.google.com |
| Message-ID | <23614233.2468.1321849696743.JavaMail.geo-discussion-forums@prfx4> (permalink) |
| References | <e9dcfb2d-dfef-4ae6-9d9f-979a8f08b962@t36g2000prt.googlegroups.com> <jabq3m$soi$1@dont-email.me> <278f7e6f-ee15-4ceb-bad7-fbb5f3e1e90b@h30g2000pro.googlegroups.com> |
On Sunday, November 20, 2011 1:11:00 PM UTC-8, sara wrote:
> Here is the code:
>
> ArrayList<Integer> tmp=new ArrayList<Integer>();
*DO NOT USE TAB CHARACTERS TO INDENT USENET CODE LISTINGS!*
> tmp.add(-1);
> tmp.add(-1);
> System.out.println(DiGraph.GetBytes(tmp).length);
> tmp.set(0, 10);
> System.out.println(DiGraph.GetBytes(tmp).length);
>
>
> public static byte[] GetBytes(Object v) {
> ByteArrayOutputStream bos = new ByteArrayOutputStream();
> ObjectOutputStream oos;
> try {
> oos = new ObjectOutputStream(bos);
> oos.writeObject(v);
> oos.flush();
> oos.close();
> bos.close();
> } catch (IOException e) {
> e.printStackTrace();
> }
> byte[] data = bos.toByteArray();
> return data;
> }
>
> The problem is I need to write multiple arraylists on disk and later
The problem is that the code you posted won't compile.
> on I update the elements of them. I store the starting location of
> arraylists and their size such that later I can refer to them. If the
> size of objects change then it messes up! Could you please help?
Java changes the sizes of things in surprising ways, and makes no promises about the size of an 'ArrayList' in the way you're asking.
What do you really want to do?
> On Nov 20, 1:05 pm, markspace <-@.> wrote:
*DO NOT TOP-POST!*
--
Lew
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Size of an arraylist in bytes sara <sarasara82@gmail.com> - 2011-11-20 13:01 -0800
Re: Size of an arraylist in bytes markspace <-@.> - 2011-11-20 13:05 -0800
Re: Size of an arraylist in bytes sara <sarasara82@gmail.com> - 2011-11-20 13:11 -0800
Re: Size of an arraylist in bytes Andreas Leitgeb <avl@gamma.logic.tuwien.ac.at> - 2011-11-20 21:58 +0000
Re: Size of an arraylist in bytes markspace <-@.> - 2011-11-20 14:08 -0800
Re: Size of an arraylist in bytes Patricia Shanahan <pats@acm.org> - 2011-11-20 14:50 -0800
Re: Size of an arraylist in bytes Arne Vajhøj <arne@vajhoej.dk> - 2011-11-20 18:06 -0500
Re: Size of an arraylist in bytes Lew <lewbloch@gmail.com> - 2011-11-20 20:28 -0800
Re: Size of an arraylist in bytes Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-11-20 16:30 -0500
Re: Size of an arraylist in bytes sara <sarasara82@gmail.com> - 2011-11-20 13:35 -0800
Re: Size of an arraylist in bytes Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-11-20 17:19 -0500
Re: Size of an arraylist in bytes Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-11-20 16:58 -0500
Re: Size of an arraylist in bytes Patricia Shanahan <pats@acm.org> - 2011-11-20 14:04 -0800
Re: Size of an arraylist in bytes Arne Vajhøj <arne@vajhoej.dk> - 2011-11-20 17:18 -0500
Re: Size of an arraylist in bytes Patricia Shanahan <pats@acm.org> - 2011-11-20 14:48 -0800
Re: Size of an arraylist in bytes Arne Vajhøj <arne@vajhoej.dk> - 2011-11-25 22:12 -0500
Re: Size of an arraylist in bytes Lew <lewbloch@gmail.com> - 2011-11-20 20:44 -0800
Re: Size of an arraylist in bytes Arne Vajhøj <arne@vajhoej.dk> - 2011-11-25 22:16 -0500
Re: Size of an arraylist in bytes Lew <lewbloch@gmail.com> - 2011-11-25 20:15 -0800
Re: Size of an arraylist in bytes Roedy Green <see_website@mindprod.com.invalid> - 2011-11-20 22:25 -0800
Re: Size of an arraylist in bytes Arne Vajhøj <arne@vajhoej.dk> - 2011-11-25 22:11 -0500
csiph-web