• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Array

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello~~
I want to being a three dimension,
but the sencond index I can not deside in advance.
This array will put large data,so the index should be exactly.
Can you have another class to slove this problem,
and please give me some example...
thank you!!
 
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Nothing to do with Servlets.
I'll move this to the Java in General (beginner) forum for you.
Dave
 
buckaroo
Posts: 401
Postgres Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


but the sencond index I can not deside in advance


What eventually decides the needed index? Is it another list, text file or DB?
You can measure the length of your list, file or DB at runtime:
int j = list.length() ; or file or record...
dimension[ i ][ j ][ k ]
Can you give an example?
[ September 15, 2003: Message edited by: Donald R. Cossitt ]
 
popoe shi
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
First I get the data from database
and define an object,put the data into three dimention
Resultset rs = stmt.executeQuery();
Object a[][][] = new Object[x][y][z];
while(!rs.next())
{
i = rs.getObject("id").intvalue();
a[i][j][0] = 123;
a[i][j][1] = 234;
a[i][j][2] = 456;
j++;
}
x will put the kind value
y is the record number
z is the field
now I put j to the y place,j is the rownum,I can use rs.getRow() to get it,
but it will bring many null space,can you help me?
 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Java doesn't have any kind of "sparse" array that only uses storage for the entries that are filled. (I remember when that was a breakthrough in Lotus 1-2-3 for DOS.) Java reserves memory for all the squares on the board whether there are checkers there or not. Maybe you could use a Map instead?

Now the Map uses memory only for what you put in it. Plus the hashtable. Would that be easier to work with?
 
popoe shi
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
m~m~
I see~~
thank you!!
 
reply
    Bookmark Topic Watch Topic
  • New Topic