write a java method follo requirements


Ques is (Given the following implementation of a partially-filled sorted array (PFSA),

  1. Write a method named ‘insert’ that is passed an int value. The method inserts the value into the array appropriately so that the array is always sorted in ascending order. Your method should resolve an attempt to add to when at max capacity with ArrayIndexOutOfBoundsException.
  2. write a method named ‘seekAndDestroy’ which is passed an int value. The method finds the value in the partially-filled array, and deletes it. The partially-filled array must then be adjusted to not leave a gap in the data. Your method should throw a custom exception called DataNotFoundExceptionwith an appropriate message if the data is not in the array, and therefore can not be deleted. Include the data value in this message.


Requirements are as followed –

** use the following libraries if needed**

import java.beans.XMLDecoder;

import java.io.FileInputStream;

import java.io.IOException;

import java.util.ArrayList;

import java.util.Comparator;

import java.io.DataOutputStream;

import java.io.Serializable;

use readObject() and writeObject Methods from library if needed