Fisher-Yates shuffle Java implementation
You are both mutating &amp; returning the value you are passing to the function.  Pick one.   Either return void or return a new array/ArrayList without mutating the input. 

Your first shuffle() method requires an ArrayList, yet any Collection which implements the List interface would work, and will work well if it has \$O(1)\$ get &amp; set complexity.  So consider loosening the type from a concrete type to the List interface.  (It will even work for LinkedList, albeit with horrible performance, but working slowly is arguably better than not being able to work at all.)



The value returned by ArrayList&lt;T&gt;::set(int idx, T obj) is the previous contents of that location.  Therefor, the temporary is not necessary.

        T temp = a.get(index);
        a.set(index, a.get(n));
        a.set(n, temp);


can become:

        a.set(n, a.set(index, a.get(n)));


or more clearly, just Collections.swap(a, n, index);.

Similarly,

        T temp = a[index];
        a[index] = a[n];
        a[n] = temp;


can also become Collections.swap(a, n, index);, a similar function which takes a T[] instead of a List&lt;?&gt; as the first argument.



Here is an implementation of your "something like K&lt;T&gt; using generics" from the comments.  And no longer coding from the hip, so the Java syntax is actually correct.

MacBook-Pro:~ aneufeld$ jshell
|  Welcome to JShell -- Version 10.0.1
|  For an introduction type: /help intro

jshell&gt; public class ShuffleTest {
   ...&gt;   public static &lt;T,K extends List&lt;T&gt;&gt; K shuffle(Collection&lt;T&gt; a, Supplier&lt;K&gt; supplier) {
   ...&gt;     K dup = supplier.get();
   ...&gt;     dup.addAll(a);
   ...&gt;     Collections.shuffle(dup);  // Or use your shuffle implementation
   ...&gt;     return dup;
   ...&gt;   }
   ...&gt; }
|  created class ShuffleTest

jshell&gt; var orig = List.of("Hello", "world");
orig ==&gt; [Hello, world]

jshell&gt; ArrayList&lt;String&gt; shuffled = ShuffleTest.shuffle(orig, ArrayList&lt;String&gt;::new);
shuffled ==&gt; [world, Hello]

jshell&gt;