If a user inputs a list of strings, I want to be able to iterate through that list and for each string in that list use that as a label for a variable. For example: User enters ["one", "three", "myVar"]. I want to instantiate a variable with name of "one", another one with the name of "three", etc. So I can have something like Integer one = 23; or String three = "hello"; How would I go about doing this in Java?
This would be pointless. To use the variables in the code you'd need to know what the user had entered. (Hacks like reflection aside.)
Almost certainly what you want is a Map
keyed on the String
entered. You still have the problem of the type of the maps value, which will depend upon exactly how you are going to use it.