Hello All,

I am having a warning issue with my code. I am trying top implement the comparator into my code. Here is the warning..

EarthquakeDataSet.java:88: warning: [unchecked] unchecked call to compare(T,T) as a member of the raw type java.util.Comparator
if (c.compare(array[low], array[start_high]) == 1)


The appropriate code line is:

if (c.compare(array[low], array[start_high]) == 1)
Basically I have Class A, Class B and private static Class C (inner class to B). I have mergesort in A, so in B i have a public method that returns an object instance of C.

A:
import java.io.File;
 
import java.io.FileNotFoundException;
 
import java.util.Scanner;
 
import java.util.Comparator;
 
import javax.swing.JOptionPane;
public class EarthquakeDataSet 
{
	private int nNumRecordsProcessed; // tracks number of records actually stored in array container
 
	private EarthquakeRecord[] reqrCollection; // reference to array which will be allocated when processing the file
	public EarthquakeDataSet() {
	}
	public long ProcessFile(String sFileName) throws Exception {
 
		Scanner scanInput = null;
 
 
		// use a try-block when opening the file to guard against file-not-found errors
 
		try {
 
			scanInput = new Scanner(new File(sFileName));
 
		} catch (FileNotFoundException e) {
 
			throw new Exception("Error opening file:" + sFileName);
 
		}
 
		int nMaxNumRecords = Integer.parseInt(JOptionPane.showInputDialog("Maximum Number of Records: "));
 
 
 
		nNumRecordsProcessed = 0; // nNumRecordsProcessed may be less then nMaxNumRecords if the array is larger than needed
 
		long lStartTime = System.currentTimeMillis();
 
		reqrCollection = new EarthquakeRecord[nMaxNumRecords];
 
		try {
 
			while (nNumRecordsProcessed < nMaxNumRecords && scanInput.hasNext()) {
 
				String sRawRecord = scanInput.nextLine();
 
				reqrCollection[nNumRecordsProcessed] = new EarthquakeRecord(sRawRecord);
				//System.out.println("test " + reqrCollection[nNumRecordsProcessed].toString() +"\n");
				nNumRecordsProcessed++;
			}
 
 
		} catch (Exception e) {
 
			throw new Exception("Input failure at record: " + nNumRecordsProcessed);
 
		}
		//Comparator c;  
		//EarthquakeRecord.CreateDepthObject();
		Comparator c = EarthquakeRecord.CreateDepthObject();
		mergeSort_srt(reqrCollection, 0, 50, c);
		for(int j = 0; j < 50; j++)
		{
			System.out.println("test11 " + reqrCollection[j].toString());
 
		}
		return System.currentTimeMillis() - lStartTime; // calculate the elapse time
 
 
	}
 
 
 
	public String toString() {
 
		return "Number of Records: " + nNumRecordsProcessed;
 
	}
 
	/******************************************************************************************************************/
 
	public void mergeSort_srt(EarthquakeRecord array[],int lo, int n, Comparator c)
	{
	    	int low = lo;
	    	int high = n;
	    	if (low >= high) 
		{
	      		return;
	    	}
		c = EarthquakeRecord.CreateDepthObject();
	    	int middle = (low + high) / 2;
	    	mergeSort_srt(array, low, middle, c);
	        mergeSort_srt(array, middle + 1, high, c);
	    	int end_low = middle;
	    	int start_high = middle + 1;
		System.out.println(c.toString());
	    	while ((lo <= end_low) && (start_high <= high)) 
		{
		      	if (c.compare(array[low], array[start_high]) == 1) 
			{
		        	low++;
			}
			else
			{
		        	EarthquakeRecord Temp = array[start_high];
		        	for (int k = start_high- 1; k >= low; k--) 
				{
		        		array[k+1] = array[k];
			        }
				array[low] = Temp;
		                low++;
		                end_low++;
		                start_high++;
		         }
		}
		reqrCollection = array;		
 
      	}
 
 
	/******************************************************************************************************************/
}

B:
public static CompareDepth CreateDepthObject()
	{	
		CompareDepth cd2 = new CompareDepth();
		return cd2;
 
	}

C:
private static class CompareDepth implements Comparator <EarthquakeRecord>
	{
		public int compare(EarthquakeRecord erq1, EarthquakeRecord erq2)
		{
			if(erq1.getDepth() < erq2.getDepth())
				return 1;
			else if(erq1.getEpicentre() > erq2.getEpicentre()) 
				return -1;
			else return 0;
		}
	}


thanks
tnamay