import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        int[][] a = {{ 1, 2 }, {3, 4, 5}};
        int[][] b = deepCopy(a);
        System.out.println(Arrays.deepToString(b));
    }
    
    private static <T> T deepCopy(T obj) {
        try {
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            ObjectOutputStream oos = new ObjectOutputStream(baos);
            oos.writeObject(obj);
            oos.close();
            ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
            ObjectInputStream ois = new ObjectInputStream(bais);
            @SuppressWarnings("unchecked")
            T result = (T) ois.readObject();
            return result;
        } catch (Exception e) {
            throw new UnsupportedOperationException(e);
        }
    }
}