That's naming a variable - not an object. Objects don't have names, as such. (You can have a field called name of course, but it's not a general thing.)
Variable names are usually only relevant at compile time - so it doesn't really make sense to do this dynamically.
It sounds like you probably want a Map<String, YourClassType> so that you can associate each object with a name and then fetch it later. So something like:
class Foo {
private final Map<String, Bar> bars = new HashMap<>();
public Bar createBar(String name) {
Bar bar = new Bar();
bars.put(name, bar);
return bar;
}
public void processBar(String name) {
Bar bar = bars.get(name);
if (bar == null) {
// No Bar for that name...
// Maybe throw an exception?
}
// Do something with bar
}
}
string objectNameas the parameter andSomeClassinstead ofobjectOfSomeKind.