human: 输出一个Java代码片段，该代码片段接受一个数字数组并返回中位数。
 bot: public class Main {

    public static void main(String[] args) {
        int[] nums = {1, 2, 3, 4, 5};
        double median = findMedian(nums);
        System.out.println("The median is: " + median);
    }

    public static double findMedian(int[] nums) {
        List<Integer> numList = new ArrayList<>();
        for (int num : nums) {
            numList.add(num);
        }
        Collections.sort(numList);
        int length = numList.size();
        if (length % 2 == 0) {
            return (numList.get(length / 2 - 1) + numList.get(length / 2)) / 2.0;
        } else {
            return numList.get(length / 2);
        }
    }
}