• 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

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: 24204
44
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.
 
On top of spaghetti all covered in cheese, there was this tiny ad:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic