Using the above code I can get the value of Tempclass fields based on enum values. Now how to set the fields of Tempclass based on enum value ex: if enum VALUE2 is selected, then i need to set the Tempclass field2 to the input value. Answer Use a BiConsumer<Tempclass, String> taking an instance of TempClass and a String and