get Class Fields Count - Android java.lang.reflect

Android examples for java.lang.reflect:Class

Description

get Class Fields Count

Demo Code


//package com.java2s;
import java.lang.reflect.Field;

public class Main {

    public static int getFieldsCount(Class<?> bean) {
        Field[] fields = bean.getFields();
        if (fields != null) {
            return fields.length;
        }// w w w .  jav a  2 s .c  o m
        return 0;
    }
}

Related Tutorials