Question: I have a POJO with loads of Strings and I want an easy method to check if they are all empty / contain a certain character / whatever. 

I get the String variables with this: 

```
    Field[] fields = this.getClass().getDeclaredFields();

    for (Field f : fields) {

        if (f.getType() == java.lang.String.class) {
            Log.d("REF", "Field: " + f.getName());
        }

    }

```

but I don't know how to get the String value of the Field. How is it done?

Answer: 
You need to call:

```
Object val = f.get(this); 

```

OR to get String object:

```
String strval = (String) f.get(this); 

```

to get field represented by f's value.

See: [`Field#Get(Object)`](http://docs.oracle.com/javase/6/docs/api/java/lang/reflect/Field.html#get%28java.lang.Object%29) 

Also: [`Getting and Setting Field Values`](http://docs.oracle.com/javase/tutorial/reflect/member/fieldValues.html)
You can try this code to get the value :

```
for (Field f : fields) {
   if (f.getType() == java.lang.String.class) {
        Log.d("REF", "Field: " + f.getName());
        String s = (String)f.get(this);
   }
}

```