I have a class. I have overridden toString value. Now I want to map the value of toString output to the class. Is there any shortcut way ?
public class Cat {
String name;
int age;
String color;
public Cat(String name, int age, String color) {
this.name = name;
this.age = age;
this.color = color;
}
@Override
public String toString() {
return "Cat{" + "name=" + name + ", age="+age+",color="+color+'}';
}
}`
in short I want to map following value to the Cat class
String value = "Cat{name=Kitty,age=1,color=Black}"
Cat cat = // create a 'Cat'from 'value'
Thank you in advance.