I have a function that gets an int value from the user and assigns it to an int id.
I have a Paper class. So what I want to do is everytime I get value from user I want to create a Paper object with that name.
For eg.
// get value from user and assign it to int id;
id= 312;
// create Paper object with value from id
Paper (value of id) = new Paper();
Variable names are a compile-time thing; they don’t exist at run-time. You probably want to use something like a map: