Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

4
  • alright, but classes will keep on changing in the loop (upwards in hierarchy), and obj will be just one object of the initial class. I will have to make object of each class first or what? Commented Mar 10, 2014 at 10:07
  • 1
    @AbdulJabbar obj is an instance of the initial class, but it's also an instance of all the superclasses of this class, so you just use obj for everything, and it will work. Commented Mar 10, 2014 at 10:12
  • Thanks, it worked. Can you help me in the part "if the field is String", can't find anyway to find that like isString(). Commented Mar 10, 2014 at 10:14
  • 1
    @AbdulJabbar if(fields[i].getType().equals(String.class)) should work. Commented Mar 10, 2014 at 10:20