java - dynamically creating objects -


I have a method that receives an array of strings and I need to create an object with the appropriate names I < / P>

For example:

  public class temp {public static zero main (string [] args) {string [] a = new string [3]; A [0] = "first"; A [1] = "second"; A [2] = "third"; CreateObjects (a); } Public static zero createObjects (string [] s) {// I have the same name int [0], s [1], s [2]; I want to keep an integer; }}   

If I get ("one", "two") then I should make:

  object one; Give the object;   

If I get ("boy", "girl") then I should make:

  object boy; Object girl;   

Any help would be appreciated.

You can create a map instead of in Java Those are key strings and value objects are there.

Comments