Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

Sorting Java Array problem?

$
0
0
Hi guys,

We are meant to create a method called sortTheArray (self explanatory)...

We are not allowed to use java.util.Arrays according to the specification even though its much easier... We have to recreate simple version of vector class hence need to write our own sorting method..

this is what I have so far...


	public void sortTheArray()
	{	
		//create a new array for holding the values of the old array.
		for (int i = 0; i < itemArray.length; i++)
		{
			for (int j = i + 1; j < itemArray.length; j++)
			{
				[b]if (itemArray[i] > itemArray[j])[/b]
				{
					Item tempValue = itemArray[j];
					itemArray[j] = itemArray[i];
					itemArray[i] = tempValue;
				}
				
			}
		}




I get the following error with the if statement..

The operator
 > 
is undefined for the argument type(s) unisa.progfund.item, unisa.progfund.item :S

Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>