title: Get object name of a class from the user in Java
body: <p>I want the user to enter the name of the object to be used in the code. For example, if I have a class</p>
  
  <pre><code>public class Person{ 
  .......
  }
  </code></pre>
  
  <p>now instead of me creating an object with a specific name like</p>
  
  <pre><code>Person student;
  </code></pre>
  
  <p>I want the user to enter the name for the object maybe like teacher, and then an object teacher of the class person will be created.
  I do not know if this is even possible in java, many of the solutions I looked up were using a map, but the explanations were not clear enough for me as I am new to java. </p>
  
  <p>So, if anyone could explain how it can be done with code snippets it would be wonderful.</p>
  
  <p>Also please explain how hashmaps work in java and if they can be used to implement the problem above. I would be really grateful if explained with code examples </p>