Mine fails for modifying the array but also for only returning positive numbers. Why does my bubble sort only seem to return positive numbers?

package com.codegym.task.task11.task1123;
public class Solution {
public static void main(String[] args) throws Exception {
int[] data = new int[]{1, 2, 3, 5, -2, -8, 0, 77, 5, 5};
Pair<Integer, Integer> result = getMinimumAndMaximum(data);
System.out.println("The minimum is " + result.x);
System.out.println("The maximum is " + result.y);
}
public static Pair<Integer, Integer> getMinimumAndMaximum(int[] array) {
if (array == null || array.length == 0) {
return new Pair<Integer, Integer>(null, null);
}
//write your code here
int n = array.length;
int temp = 0;
int max = array[array.length-1];
int min = array[0];
for(int i=0; i < n; i++){
for(int j=1; j < (n-i); j++){
if(array[j-1] > array[j]){
//swap elements
temp = array[j-1];
array[j-1] = array[j];
array[j] = temp;
}
}
}
return new Pair<Integer, Integer>(min, max);
}
public static class Pair<X, Y> {
public X x;
public Y y;
public Pair(X x, Y y) {
this.x = x;
this.y = y;
}
}
}