This is legal Java:
Class<?>[] classes = new Classes<?>[] { foo, bar };
builder.setCategories(classes);
classes[1] = baz;
This explicit copy prevents the builder (actually and more importantly its toReturn) from being modified from the outside: toReturn.categories is guaranteed to contain foo and bar, and not baz.
This is a standard pattern. Not doing the copy would actually be flagged as a possible source of error by things like Checkstyle and/or Findbugs (can't remember which ones flags this).