I would like to check if two Java objects are equal. This check should also work for arrays. I wrote this:

```
/** Check if two Java objects are equal. */
private static <T> boolean equal (T a, T b)
{
  if (a == null)
    if (b == null)
      return true;
    else
      if (b.getClass().isArray())
        return Arrays.equals(b, a);
      else
        return b.equals(a);
  else
    if (a.getClass().isArray())
      return Arrays.equals(a, b);
    else
      return a.equals(b);
}

```

But calling `Arrays.equals` fails to compile with the following error:

```
no suitable method found for equals(T,T)

```

How can I fix this?