title: Check if java.lang.reflect.Field type is a byte array
body: <p>I don't do much of reflection so this question might be obvious. For e.g. I have a class:</p>
  
  <pre><code>public class Document {
  
      private String someStr;    
  
      private byte[] contents;  
  
      //Getters and setters
  
  }
  </code></pre>
  
  <p>I am trying to check if the field <code>contents</code> is an instance of byte array. What I tried:</p>
  
  <pre><code>Class clazz = Document.class;
  Field[] fields = clazz.getDeclaredFields();
  for (Field field : fields) {
      if (field.getType().isArray()) {
          Object array = field.getType();
          System.out.println(array);
      }
  }
  </code></pre>
  
  <p>The output of this code is: <code>class [B</code>. I see that byte array is found, but if I do:</p>
  
  <pre><code>if (array instanceof byte[]) {...}
  </code></pre>
  
  <p>This condition is never <code>true</code>. Why is that? And how to check if the object contains fields which are of type of <code>byte[]</code>?</p>