How to swap rows and columns of a 2d array?

I’m trying to write a method for ‘transpose’ a two-dimensional array of integers, in which the rows and columns of the original matrix are exchanged. However, I have no idea how I can realize this. …