• 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

RunTime Dynamic String Array split?

 
Ranch Hand
Posts: 223
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I have String array like

String arr[] = {"one","two","three","four","five","six","seven","eight"};

e.g
I have done like this.

List testData = new ArrayList();
Map map1 = new TreeMap();
Map map2 = new TreeMap();

map1.put("1",arr[0]);
map1.put("2",arr[1]);
map1.put("3",arr[2]);
map1.put("4",arr[3]);
testData.add(audit1);

map2.put("1",arr[4]);
map2.put("2",arr[5]);
map2.put("3",arr[6]);
map2.put("4",arr[7]);
tes2Data.add(audit2);

IS OTHER ANY GOOD WAY TO PUT DIFFERENT MAP,ARRAY LIST IN RUN TIME?
Thanks
 
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
what are audit1, audit2 here ? i don't understand your question. What is the criteria for splitting?
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Perhaps this is better suited to Java in General (Beginner).
 
Edward Durai
Ranch Hand
Posts: 223
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I have String array like

String arr[] = {"one","two","three","four","five","six","seven","eight"};

e.g
I have done like this.

List testData = new ArrayList();
Map map1 = new TreeMap();
Map map2 = new TreeMap();

map1.put("1",arr[0]);
map1.put("2",arr[1]);
map1.put("3",arr[2]);
map1.put("4",arr[3]);
testData.add(map1);

map2.put("1",arr[4]);
map2.put("2",arr[5]);
map2.put("3",arr[6]);
map2.put("4",arr[7]);
tes2Data.add(map2);

IS OTHER ANY GOOD WAY TO PUT DIFFERENT MAP,ARRAY LIST IN RUN TIME?
Thanks
 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here is another way.



Your example is not really real world because you dont always know know the size of your array and you would be loading your maps on the values in your array instead of just position.
 
If I had asked people what they wanted, they would have said faster horses - Ford. Tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic