title: In Java, can I create an object with a name passed by a String?
body: <p>I want to do something like this:</p>
  
  <pre><code>Creator method = new Creator();
  method.addSubject("example");
  
  class Creator{
    public void addSubject(String subjName) {
       //here is the issue
       subjName = new Subject(subjName);
    }
  }
  
  class Subject {
    private String name;
    public Subject(String newName) {
      name = newName;
    }
  }
  </code></pre>
  
  <p>So I want this class called Creator to be able to make Subjects, but I need it to be able to do so by passing it a String with the name that I want to call those subjects. How can I do this?</p>
  
  <p>Edit: To clarify, the class "Creator" has a method called "addSubject". In the main method of the program I have an object of Creator called "method" (probably should have chosen a better example name). So can this object of Creator make objects of another class, class "Subject", simply by passing the method "addSubject" the name I want those objects of Subject to have?</p>
  
  <p>Edit2: This is the pseudocode of what I want:</p>
  
  <pre><code>Main method:
  Initialize Creator object
  Command line for program takes arguments
  Pass these arguments to creator object
  
  Creator Object:
  Takes command line argument in the form of string and makes a new object of the class Subject by the name of the String
  </code></pre>