lundi 26 novembre 2018

How to convert field to an object by creating instance in reflection java? [duplicate]

This question already has an answer here:

in My code, I want to an object from Field reflection. How to do it? Problematic code is in if statement

  public class PersonelKatilimRaporDto {
      String personelAdiSoyadi;
      PersonelKatilimDto dayOf1;
      PersonelKatilimDto dayOf2;
  }

 Class personelKatilimRaporDto = PersonelKatilimRaporDto.class;
    Field[] attributes= personelKatilimRaporDto.getDeclaredFields();

   for (Field attribute:attributes)
   {
      if( attribute.getType()==PersonelKatilimDto.class)
      {
         // attribute=new PersonelKatilimDto(katilimDurumu,startHour,finishHour);
      }





Aucun commentaire:

Enregistrer un commentaire