maximum method for UnorderedArrayList
I have created the following method in UnorderedArrayList but am having problems calling it from a test class to show that the method works.
publicclass UnorderedArrayList<T>extends ArrayListClass<T>
{
public <Textends Comparable><T> >int maximum()
{
int maxLoc = 0;
if (length == 0)
System.out.println("No items in the list.");//return null; // if no items have been put in list, return null
else
{
for (int loc = 1; loc < length - 1; loc++)// loop through items in list
{
if (larger((T)list[maxLoc], (T)list[loc])== (T)list[loc])// if larger returns the current item, set maxLoc to current location
maxLoc = loc;//max = (T)list[loc];
}
return maxLoc;
}
}
publicclass test
{
UnorderedArrayList<Integer> UAL3 =new UnorderedArrayList<Integer>(5);
UAL3.insertAt(0, 30);
UAL3.insertAt(1, 3);
UAL3.insertAt(2, 70);
UAL3.insertAt(3, 65);
UAL3.insertAt(4, 34);
System.out.println("Original list:");
UAL3.print();
System.out.println("Max: " + UAL3.list[UAL3.maximum()]);
On this second part, I am receiving the error:
test.java:56: incompatible types; inferred type argument(s) java.lang.Object do not conform to bounds of type variable(s) T
found: <T>int
required: int
System.out.println("Max: " + UAL3.list[UAL3.maximum()]);
If I take out the <T extends Comparable><T> > in maximum, the call from test works but then the call to larger does not.
Any help would be appreciated. Thank you

