Java Field.toString()

Syntax

Field.toString() has the following syntax.

public String toString()

Example

In the following code shows how to use Field.toString() method.


import java.lang.reflect.Field;
/*w  ww.j  ava  2  s.  co  m*/
public class Main {
  public static void main(String args[]) throws Exception{
      Class c = Class.forName("java.awt.Dimension");

      Field fields[] = c.getFields();
      for (int i = 0; i < fields.length; i++) {
        System.out.println(fields[i].toString());
      }
  }
}

The code above generates the following result.





















Home »
  Java Tutorial »
    java.lang.reflect »




Array
Constructor
Field
Method
Modifier
ParameterizedType
TypeVariable