• Post Reply Bookmark Topic Watch Topic
  • New Topic

RunTime Dynamic String Array split?  RSS feed

 
Edward Durai
Ranch Hand
Posts: 223
  • Mark post as helpful
  • send pies
  • 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
 
Serkan Demir
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what are audit1, audit2 here ? i don't understand your question. What is the criteria for splitting?
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • 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
  • 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
 
Joe Urbanek
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • 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.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!