title: Java - How to create a class instance from user input
body: <p>I want this program to ask the user for input, and create a class instance with a name equal to the input of the user. Then, the createMember class will create a text file, where all the data of the user will be stored. How do I go about doing it?</p>
  
  <p>Here's the main method:</p>
  
  <pre><code>     public static void main(String[] args) {
  
           String input = keyboard.nextLine();        
           input = new createMember(); // Error. can't do that for some reason?
      }
  }
  </code></pre>
  
  <p>Here's the createMember class</p>
  
  <pre><code>public class createMember {
  
  public void setMembership() {
      Scanner keyboard = new Scanner(System.in);
      out.println("Username: ");
      String input = keyboard.nextLine();
  
      try { 
          //Creates a text file with the same name as the username where data is stored.
          Formatter x = new Formatter(input);       
      } catch (Exception e) {
          out.println("Could not create username");
      }
  }
  
  //Methods for the user
  </code></pre>
  
  <p>Guys... I know I can simply create an instance like this:</p>
  
  <pre><code>  createMember member = new createMember();
  </code></pre>
  
  <p>What I actually want to do is HAVE THE USER do that on his own, so the program is flexible and usable for many people. So, based on the input, there will be a separate folder that stores the data for each user.</p>