Design an algorithm to find all pairs of integers within an array which sum to a specified value.
import java.util.*; public class sumtoValue { public static void sumtoValue(int[] array, int value){ Arrays.sort(array); int first = 0; int last = array.length - 1; int sum = 0; while(first < last){ sum = array[first] + array[last]; if(sum== value){ System.out.println("sum is " + array[first] + "+" +array[last]); break; } else{ if(sum > value){ last--; } else{ first++; } } } } public static void main(String[] args){ int[] array = {1,2,3,4,5}; sumtoValue(array,4); } }