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.
public class UnorderedArrayList<T> extends ArrayListClass<T>
  public <T extends 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;
public class 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

If I take out the < T extends Comparable<T> > in
maximum, the call from test works but then the call
to larger does not.You'll have to remove one return type. Either return a T (without the extends stuff behind it) or return an int.
You could try this (untested!) code:public class UnorderedArrayList< T extends Comparable <T> > extends ArrayListClass<T> {
    public T maximum() {       
        if (length == 0) {
            return null;
        T max = list[0];
        for (int i = 1; i < length-1; i++) {
            T temp = list;
if (max.compareTo(temp) < 0) {
max = temp;
return max;
Checkout this tutorial on generics:
http://java.sun.com/j2se/1.5/pdf/generics-tutorial.pdf

Similar Messages

  • Error: No permitted payment method for Payment Praposal in F110

    Hello Experts,
    I am trying to tigger an Idoc for payment from F110 and am getting the following error:
    Job started                                                                       
    Step 001 started (program SAPF110S, variant &0000000002133, user ID )       
    Log for proposal run for payment on 27.01.2005, identification                                                                               
    Additional log for vendor 3803 company code 3000                                                                               
    Due date determination additional log                          
    Document 1900004238 line item 002 via USD      100.000,00-                
    Terms of payment: 27.01.2005    0  0,000 %    0  0,000 %    0             
    03 days grace period is being considered                                  
    Payment must take place before 30.01.2005; next payment on 26.04.2008     
    Item is due with 0,000 % cash discount                                                                               
    Payment method selection additional log                               
    Payment method selection for items due now to the amount of USD      100.000,00- 
    Payment method "C" is being checked                                              
    Bank details are being checked                                                   
    System reads house banks and checks if they are allowed                        
    Our bank 3000 is being checked                                                   
    Bank different from the specified bank DBKA in master record or items            
    Our bank 3200 is being checked                                                   
    Bank different from the specified bank DBKA in master record or items            
    House bank is selected ...                                                     
    No permitted payment method exists                                               
    Information re. vendor 3803 / paying company code 3000 ...                         
    ... payment not possible because of reported error  
    End of log                                                                         
    Step 002 started (program SAPFPAYM_SCHEDULE, variant &0000000001217, user ID )
    Step 003 started (program RFFOEDI1, variant &0000000000042, user ID )        
    Program RFFOEDI1: No records selected                                              
    Step 004 started (program RFFOAVIS, variant &0000000000044, user ID )       
    Program RFFOAVIS: No records selected                                             
    Job finished   
    Plesase suggest its very urgent.
    Thanks,
    Suma
    Edited by: Suma B on May 3, 2008 9:42 AM

    check payment in vendor master or invoice line items. May be payment method entered in parameters is different from vendor master data and invoice.
    Check Payment method configuration for country and Company code
    In Payment method for company code
    check
    minimum and maximum amount
    foreign payments allowed or not
    Check Bank determination for paying company code combination with payment method

  • Error in Pre- Export methods for a request

    Hi All,
    I am getting an error while releasing a request, its giving
    "Error in Pre- Export methods for a request DM0k.....". Could you please tell me why and how can I rectify that?
    Thanks.
    NA

    Please go through as per the link
    [SAP Transport Request |http://www.sap-basis-abap.com/sapbs008.htm]
    thanks
    G. Lakshmipathi

  • Set Maximum size for a subpanel created with splitter bars in LV8

    Does anyone know how to set the Maximum size for a subpanel created with asplitter bar? If I show one cluster in the subpanel and use the scroll bar to scroll, I can see more (blank) area than I want. I just want the user to be able to scroll a cluster within a subpanel while the cluster is larger than the view area of the subpanel. I don't want to let the user scroll outside the cluster.
    Ravi Beniwal

    I apologize for the mixup in terminology. Please read Pane wherever the word Subpanel was used.
    Please see the attached VI for a description of my problem.
    I would really appreciate any help with this.
    Ravi Beniwal
    Attachments:
    Pane Scrolling Problem.vi ‏10 KB

  • How to find a badi and how to find the method/methods for a transaction?

    Hi all,
    i need to give a text either while creating customer (vd01) or changing customer(vd02)...thsi is via extras->texts.....then I have to double clik the text and go to change editor...and then i have to clik on insert line and then choose text element radiobutton on screen and then give it a name and then save it..this should be done for all customers....my problem is i am unable to find a badi and the appropriate method for thsi..i have placed break point in method read_add_on_data in the badi customer_add_data....i tested both by transactions va01 and va02 but of no use..also there are so many methods..can u tell me how do i find the appropriate method of the appropriate badi.....

    Hi,
       For XD01/XD02/XD03 The following BADI's are useful
    business Add-In CUSTOMER_ADD_DATA  and  business Add-In CUSTOMER_ADD_DATA_CS .
    *<b>Reward points</b>
    Regards

  • Oracle.jbo.AttrValException: JBO-27019: Get method for attribute

    Hi Guys,
    I am trying to add a new column to Oracle quoting.It has already been customized by some consultant few years back. I followed the note 392728.1 on metalink and also have the documentation by the previous consultant but getting the error oracle.jbo.AttrValException: JBO-27019: Get method for attribute Draft in HeaderVO could not be resolved after adding my column, when I try to print the quote.
    Here are the steps I took
    1) added a column to the query (at the end) in HeaderVO.xml
    2) added the below code in the HeaderVO.xml
    <ViewAttribute
    Name="DRAFT"
    IsQueriable="false"
    IsPersistent="false"
    Precision="100"
    Type="java.lang.String"
    AliasName="DRAFT"
    ColumnType="VARCHAR2"
    Expression="DRAFT"
    SQLType="VARCHAR" >
    <DesignTime>
    <Attr Name="_DisplaySize" Value="100" />
    </DesignTime>
    </ViewAttribute>
    3). Modify HeaderVORowImpl.java file to add setters and getters for the newly added view attribute. For example,
    a) case 67: //
    setDRAFT((String)obj);
    return;
    b) case 67:
    return getDRAFT();
    c) ublic void setDRAFT(String s)
    setAttributeInternal(67, s);
    public String getDRAFT()
    return (String)getAttributeInternal(67);
    d) protected static final int DRAFT = 67;
    Everything is dont exactly as per the manual but not sure why I am getting this issue. Any help will be appreciated.

    a) case 67: //
    setDraft((String)obj);
    return;
    b) case 67:
    return getDraft();
    c)public void setDraft(String s){
    setAttributeInternal(67, s);
    public String getDraft(){
    return (String)getAttributeInternal(67);
    d) protected static final int DRAFT = 67;
    can u change it as explained above.. setDRAFT should be setDraft.. and getDRAFT should be getDraft..
    and make sure that the index.. number is exactly matching with the attribute order in the VO

  • My previous method for payment on itunes was debit card but now I dont have one.  How do I change to no card without creating a new apple id

    My previous method for payment on itunes was debit card but now I dont have one.  How do I change to no card without creating a new apple id?  It tells me to update payment details when I try to update apps but it only has visa, mastercard, amex and maesto.  I dont have any of them.  I did previously use visa but I dont have the card anymore and cant get another one.  Please can someone help me set it up so I dont need a payment method.  Thanks

    Thanks for you reply.  Is that the only way as it would cost me £15?

  • How to use the index method for pathpoints object in illustrator through javascripts

    hii...
    am using Illustrator CS2 using javascripts...
    how to use the index method for pathpoints object in illustrator through javascripts..

    Hi, what are you trying to do with path points?
    CarlosCanto

  • What is the direct connect method for transfering photos from my macbook pro to my iphone without using iTunes syncronization? (iow: a simple photo copy from mac to iphone?)

    I feel like I should know the answer to this. I can't believe it is a hard question.
    What is the direct connect method for transfering photos from my macbook pro to my iphone without using iTunes syncronization? (iow: a simple photo copy from mac to iphone?)
    Easy? Right?
    Just plug my iphone in to a mac and copy a photo from the mac to my iphone.
    I don't have internet access - I can't email it, or mobileme it, or dropbox it.

    iTunes. Other than that there is no direct method. However, do try the iPhone forums.

  • I already have a valid payment method for my iTunes account, but can't get past the Family Sharing setup prompt telling me to add a payment method . What to do?

    I already have a valid payment method for my iTunes account, but can't get past the Family Sharing setup prompt telling me to add a payment method . What to do?

    I had the same problem and found a bunch of others did, too.  Unfortunately all the posts had no responses!  Anyway, I previously had my payment method linked to my paypal.  I tried changing it to my credit card and it worked.  Don't know if there's a bug with using paypal but that seemed to be the culprit for me.  Good luck!

  • How do i get a list of all Roles defubed under a particular OrganizationalUnit? How can i use LDAPConnection.search method for this?

     

    Sorry for the typographical mistake.
    Please read the question as:"How do i get a list of all Roles defined under a particular OrganizationalUnit? How can i use LDAPConnection.search method for this?"

  • Error : FZ010 : Enter a payment method for incoming payments

    Hi,
    I am running F110 and paying intercompany vendors/customers.
    I am running payment run for Compony 0050 and paying my vendor VEND0060 and CUST0060.
    The balance of vend0060 is 2 million(credit) and  balance of CUST0060 is 1 million (Debit).
    So I am going in Reallocate and changing the bank details as getting exceptioin in CUST0060. But it gives out an error "Enter Payment method for incoming payments"
    We have just configured outgoing payment and actually as credit balance is more, it should not give this error.
    Does any one know solutin for this?
    Error in details:
    Enter a payment method for incoming payments
    Message no. FZ010
    Diagnosis
    The balance of the items to be paid requires a payment method for incoming payments. You specified a payment method that is defined for outgoing payments.
    System Response
    The payment method is rejected.
    Procedure
    Enter a payment method for incoming payments.
    Thanks
    JR

    In the master record of the customer/vendor, ensure that the appropriate payment methods are maintained.  If you click on F4 on the payment method field, you can see different methods available for Incoming Payments and different methods for Outgoing payments.
    Assign points accordingly.
    Thanks,
    Madhav Nanduri

  • Calling a method for various files

    I am having a method with 500 lines.
    I need to call the same method for more than 50 files.
    How do I call the method.

    I would love to help you.
    But I'm SO confused.
    Can you try to be more specific?

  • Is there a reliable method for detecting that a query is too large?

    I am writing some code (that uses OCI) to properly detect when a query string is too long for OCI and/or the Oracle database server. I can't find any specific error code information in the docs, so I just started firing off large queries to see what would happen.
    The queries I am sending are >2MB in size, up to 16MB. If the queries are above ~10MB, I get the error "ORA-03113 'End-of-file on communications channel'" after a fairly short amount of time (i.e. not enough for a timeout to expire). If the queries are below ~10MB, but above ~2.5MB, it either just sits there and does not do anything (for more than 15 hours). So watching for ORA-03113 when executing large queries does not seem like a very reliable method for detecting the queries that are too large.
    Does anyone know of a reliable way of detecting that a query is too large for the OCI client and/or the Oracle database server?
    I am using version 10.2.0.1 for both the OCI client and the Oracle database server, but I'm getting similar errors for combinations of 10.2.0.1 and 9.2.0.7 for both the OCI client and the Oracle database server.
    These large queries need to be handled properly (i.e. distinguished from some generic failure) because the server handles requests from users, which could be programs that generate SQL queries (and have constructed huge ones in the past).
    Thanks for any information!

    The ORA-03113 means that the Oracle server process has died trying to satisfy your request. In almost all cases it is strictly correct to call that a bug, and we shouldn't easily forgive the server process when it happens. But in the case of multimegabyte statements my anger and disapointment turns to sympathy, for in my heart I can't bring myself to blame it. Can you?

  • Can someone please tell me a simple but effective method for burning a slideshow to DVD? Now that the connection between iPhoto and iDVD no longer exists, I can't figure out a way to get there with an acceptable quality result.

    Can someone please tell me a simple but effective method for burning a slideshow to DVD? Now that the connection between iPhoto and iDVD no longer exists, I can't figure out a way to get there with an acceptable quality result.

    Export the slideshow out of iPhoto as a QT movie file via the Export button in the lower toolbar.  Select Size = Medium or Large.
    Open iDVD, select a theme and drag the exported QT movie file into the open iDVD window being careful to avoid any drop zones.
    Follow this workflow to help assure the best qualty video DVD:
    Once you have the project as you want it save it as a disk image via the File ➙ Save as Disk Image  menu option. This will separate the encoding process from the burn process. 
    To check the encoding mount the disk image, launch DVD Player and play it.  If it plays OK with DVD Player the encoding is good.
    Then burn to disk with Disk Utility or Toast at the slowest speed available (2x-4x) to assure the best burn quality.  Always use top quality media:  Verbatim, Maxell or Taiyo Yuden DVD-R are the most recommended in these forums.
    If iDVD was not preinstalled on your Mac you'll have to obtain it by purchasing a copy of the iLife 09 disk from a 3rd party retailier like Amazon.com: ilife 09: Software or eBay.com.  Why, because iDVD (and iWeb) was discontinued by Apple over a year ago. 
    Why iLife 09 instead of 11?
    If you have to purchase an iLife disc in order to obtain the iDVD application remember that the iLife 11 disc only provides  themes from iDVD 5-7.  The Software Update no longer installs the earlier themes when starting from the iLIfe 11 disk nor do any of the iDVD 7 updaters available from the Apple Downloads website contain them. 
    Currently the only sure fire way to get all themes is to start with the iLife 09 disc:
    This shows the iDVD contents in the iLife 09 disc via Pacifist:
    You then can upgrade from iDVD 7.0.3 to iDVD 7.1.2 via the updaters at the Apple Downloads webpage.
    OT

Maybe you are looking for