java - combine two array string to make a list -
i working on own personal app minecraft. forget recipe need, , search, , have display recipe.
now, have list , search function beingness alphabetical. manually adding images, , else need. think more efficient if had array string this
string test1[] = { "diamond", "iron", "leather" }; string test2[] = { "leggings", "boots", "helmet", "chestplate" }
and in list view want end result this.
diamond leggings diamond boots diamond helmet diamond chestplate iron leggings ... ... gold leggings ... ... ...
what need accomplish that? think ineffecient if did test3.add("diamond chestplate") test3.add("diamond boots") etc.. .. ...
and end having big list instead can combine them.
if understand question, nested for-each
loop(s) like
string test1[] = { "diamond", "iron", "leather" }; string test2[] = { "leggings", "boots", "helmet", "chestplate" }; list<string> al = new arraylist<>(); (string : test1) { (string j : test2) { stringbuilder sb = new stringbuilder(i); sb.append(' ').append(j); al.add(sb.tostring()); } } system.out.println(al);
java android arrays
No comments:
Post a Comment