package com.foo.bar; import java.util.*; public class Test { Set intsSet; public Test() { this.intsSet = new HashSet(); } public T[] getObjs(T[] a) { return intsSet.toArray(a); } public static void main(String[] args) { System.out.println("AAA :-)"); new TTT().foo(); } } class TTT { public void foo() { Test mt = new Test(); Object[] arr = mt.getObjs(new Object[]{}); } }