This is the solution by me. getting wrong output while sorted array length is even and testcases are failing.
public double findMedianSortedArrays(int[] nums1, int[] nums2) {
        int m= nums1.length;
        int x=nums2.length;
        int n=m+x;
        int[] Sortedarray= new int[n];
        int i=0;
        int k=0;
        for(int j=0;j<n;j++){
            if(i<m&&k<x){
                if(nums1== null || nums1[i]>nums2[k]){
                    Sortedarray[j]=nums2[k];
                    k++;
                }
                else{
                    Sortedarray[j]=nums1[i];
                    i++;
                    }
            }
        }
        double median=0;
        if(n%2 == 0){
            median= (Sortedarray[n/2]+ Sortedarray[(n/2)-1])/2;
        }
        else{
            median=Math.floor(Sortedarray[n/2]);
        } 
        return median;
}
for better understanding of the given question, please follow the below instructions. Given two sorted arrays nums1 and nums2 of size m and n respectively, return the median of the two sorted arrays. ex1: Input: nums1 = [1,3], nums2 = [2] Output: 2.00000 Explanation: merged array = [1,2,3] and median is 2.
ex2: Input: nums1 = [1,2], nums2 = [3,4] Output: 2.50000 Explanation: merged array = [1,2,3,4] and median is (2 + 3) / 2 = 2.5.
 
    