java - Multi type, Multi Dimentional Arrays -


looking ways achieve in java define multi dimensional arrays each index being of different type

something this...

below 'values' , 'activities' related.. lack of such structure declared independently.

final string[] values = new string[]{         "config",         "linking twitter & facebook",         "facebook direct",         "twitter direct",         "action bar (profiled)",         "sharing",         "comments",         "likes",         "views",         "entities",         "user profile (profiled)",         "actions (user activity)",         "subscriptions",         "location",         "init",         "tools"     };      final class<?>[] activities = new class<?>[]{         authbuttonsactivity.class,         facebookactivity.class,         twitteractivity.class,         actionbaractivity.class,         shareactivity.class,         commentactivity.class,         likeactivity.class,         viewactivity.class,         entityactivity.class,         useractivity.class,         actionactivity.class,         subscriptionactivity.class,         locationactivity.class,         initactivity.class,         toolsactivity.class     }; 

it should have been declared this.. if java had support..

array<string, class>[][] valueclasses =    final array<string, class>[][] valueclasses = new array<string, class>[][]{         {  "config",  authbuttonsactivity.class },     }; 

you can use implementation of map interface. initialization code can become this:

private static map<string, class<?>> assembleactivitiesmap() {   map<string, class<?>> activities = new hashmap<string, class<?>>();    activities.put("config", authbuttonsactivity.class);   activities.put("facebook", facebookactivity.class);   ...   return activities;  private final map<string, class<?>> activities = assembleactivitiesmap(); 

Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -