Look at the reflection package and the Class class. They have methods to create objects from existing class definitions and to access methods and fields in those objects.
public Object method(String className, String attributeName){
String attributeValue="testData"
className.attributeName = attributeValue;
return className;
}
Returning the variable className doesn't make sense here. You've defined it to be a String. The String class does NOT have a field named attributeName.
The syntax of using the reflection package classes and methods is different, but they will allow you to access public fields in an object by a name given as a String. Specifically look at the Field class.