Note: exec7.java uses unchecked or unsafe operations.Note: Recompile with
this is my first semester with Java and I am having some troubles with this program that I am attempting to finish. Ideally the program is bubble sorting 2 seperate arrays and then combining them into a 3rd bigger array. I am not completely finished but I am having this compiling error when I am attempting to compile as I go.
Note: exec7.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
I am using the API for some wording on the comparable interface parameters. I thought that I did everything that it referenced, but obviously I am overlooking something ...
here is all of my current code:
import java.io.*;
import java.util.*;
public class exec7
{
public static Integer arr1[] = {99,30,27,36,34,95,86,65,45,3,4,9,11,12,85,35,54,6,13,22,23,14,15,21,24};
public static Integer arr2[] = {85,75,87,66,45,58,61,52,42,72,82,1,2,5,92,37,0,7,16,18,17,19,10,20,8};
public static Integer arr3[] = new Integer[50];
public static void main(String [] args)
{
exec7 sort = new exec7();
sort.bubble(arr1);
sort.bubble(arr2);
sort.print(arr1);
sort.print(arr2);
sort.order(arr1);
}
public void bubble(Comparable arr[])
{
Comparable temp;
for(int pass = 1; pass<arr.length; pass++)
for(int pair=1;pair<arr.length;pair++)
if(arr[pair-1].compareTo( arr[pair]) >< 0)
{
temp = arr[pair-1];
arr[pair-1] = arr[pair];
arr[pair] = temp;
//sort.order(arr1,arr2);
}
}
public void print(Comparable arr[])
{
for(int j=0; j<arr.length;j++)
System.out.print(arr[j] + " ");
System.out.println();
}
public void order(Comparable arr[])
{
Comparable temp;
for(int j=1;j<arr.length;j++)
for(int k=1;k<arr.length;k++)
{
if(arr[k].compareTo(arr[k-1]) >< 0){
temp = arr[k-1];
arr[k-1] = arr[k];
arr[k]=temp;
}
}
// System.out.println(arry);
System.out.println(arr);
}
}

