Use a HashtableTag(s): Language
Hashtables are very useful for maintaining a 1-to-1 relationship between Objects. With an arbitary key, you can retrieve easily an Object. In the following example, we retrieve a String array with a String.
  String[] array1 = {"A","B","C"};
  String[] array2 = {"X","Y","Z"};
  String[] array3 = {"1","2","3"};
  Hashtable arrays = new Hashtable();
  arrays.put("Array1", array1);
  arrays.put("Array2", array2);
  arrays.put("Array3", array3);
  String[] resultArray = (String[])(arrays.get("Array2"));
  System.out.println
    (resultArray[0] + ", " + resultArray[1] + ", " + resultArray[2]);
  mail_outline
Send comment, question or suggestion to howto@rgagnon.com
Send comment, question or suggestion to howto@rgagnon.com