How to convert the string back to object? I have the following class:
class Test {
String name;
String value;
String testing;
@Override
public String toString() {
return "Test{" +
"name='" + name + '\'' +
", value='" + value + '\'' +
", testing='" + testing + '\'' +
'}';
}
}
class Testing {
private List<Test> testing = new ArrayList<Test>();
handling(testing.toString())
public String handling(String testing) {
// do some handling and return a string
}
}
ArrayList testing must handled by convert to string, for example, after that, we get the following string:
[Test{name='name1', value='value1', testing='testing1'}, Test{name='name2', value='value2', testing='testing2'}, Test{name='name3', value='value3', testing='testing3'}]
then how to convert the string back to object list of Test?
Can anyone help on it?
List<Test>within scope, but you could always add a static utility method to yourTestclass that would de-serialize a givenStringrepresentation back into aTestinstance.