Can someone explan to me

this method is part of my lab, it should sort words in alphabetical order from
from A to Z . .
i don;t undersatand why did we use .compareTo in this method??
could someone explain what does this method mean
public static void sortList()
          String temp;          
          for(int k = 0; k < count-1; k++)
         for(int p = k+1; p < count; p++)
          if(list[k].compareTo(list[p]) > 0)
                    temp = list[k];
                    list[k] = list[p];
                    list[p] = temp;
}

If all of the elements in a collection implement the Comparable interface, which defines the compareTo method, then the sorting can be done automatically using a TreeSet( ), TreeMap( ), or Collections.sort( ) method. For example:
public class MyClass
implements Comparable
   public int compareTo( Object o )
      if( equals( o ) ) return 0;
      if( o == null ) return -1;
      if( !(o instanceof MyClass) ) throw new ClassCastException( );
      MyClass that = (MyClass)o;
      if( this.getValue( ).lessThan( that.getValue( ) )
          return -1;
      else
          return 1;
public class SomeOtherClass
    public void someMethod( )
        List myClassList = new ArrayList( );
        for( int i = 0; i < 10; i++ ) myClassList.add( new MyClass( ) );
        // Sorts myClassList by casting each element to Comparable
        // and calling compareTo( )
        List sortedList = Collections.sort( myClassList );
}

Similar Messages

  • Can someone at least give an explanation why the phone suddenly goes dead ?I've experience it and the only way to turn it on is to do a hard reset.Is it a software design.technical explanation please.Thanks

    Can someone at least give an explanation why the phone suddenly goes dead ?I've experience it and the only way to turn it on is to do a hard reset.Is it a software design.technical explanation please.Thanks

    Make sure the battery is charged.
    If it's not a battery issue, restore your iPhone.
    iTunes: Backing up, updating, and restoring your iPhone, iPad, or iPod touch software

  • Can someone give a explan what the System Performance indicators mean?

    Can someone give a explan what the System Performance indicators mean?
    Audio & Disk I/O
    Thank you,
    Scott
    G5 Dual 2.0 - 2.5 Gigs Ram   Mac OS X (10.3.9)  

    Hi Scott!
    Audio is your CPU activity, and Disk i/o is the amount of bandwidth you're using when streaming files from the hard drive (audio files and sample streaming).

  • Just bought an ipad air and I have an ipad 2.  I would like to use both with the same computer.  Can someone tell me how to do this.  Do I have to set up a separate user.

    I just ordered an ipad air and I have an ipad 2. Can someone help me so I can use both ipads from the same computer.  The new one is for my husband and I am going to take the ipad 2.  Do I have to do something different since they will be using the same computer.  Any help you can give me would be appreciated.  Thanks in advance for your help.

    It's no problem. I hope this explanation simplifies the information in the Link Demo gave you. It's how I think most people do it...
    To avoid having to pay again for apps you have already purchased, use the same Apple ID (likely the current one) on both devices. You can adjust this in:
    Settings > iTunes & App Store.
    So that you can communicate with each other, use separate Apple IDs for iCloud, Messages, and FaceTime. Adjust those in:
    Settings > iCloud
    Settings > Messages
    Settings > FaceTime

  • Can someone please help me figure out why I keep getting the "can not reach server" when I try to download the ebook? This is happening with Adobe Digital Editions.

    When I try to download the ebook I bough, the Adobe Digital Reader shows the following message: "can not reach server".  Can someone please help me with this?
    TO be precise, it says "licensee server communication problem"
    Thank you

    The thread running through your explanation has to do with connectivity to your server. (iCloud out of the blue asking for password, unable to message your boyfriend, unable to access e-mail). You said that you boyfriend restart his device and then the two of you were able to then imessage. My best advice for you would be to go to settings to reset to reset network settings. Once this has been done you then will need to enter the name and password of your wifi. ONce this is done you then can attempt to check to see that all passwords are enter correctly.
    Good luck.

  • Terrible Service from BT - Can someone please help...

    To make a long story short I have bullet pointed my current experience with BT;
    Hi purchased BT Infinity their top package at the time (Unlimited BT Infinity 2) on the 11/11/12 Order number #(REMOVED)
    BT Engineer came and installed BT Infinity on the 12th December line – I went onto the BT Sainburys Voucher Redeem page and filled out all the information to claim my vouchers.
    We then fitted our BT phone – this is where it starts
    When someone calls we get a connection loss of normally 30 seconds before internet is restored
    When we end a call we get a disconnect of 5-6 minutes before connection is restored
    Yes the phone is connected to the “Master” socket that BT fitted when they came to install BT InfinityI then called their “technical” team whom read from their script off the screen for a full hour then performed some tests for 24 hours and called me back the next day to tell me to tell me what I already know that I am getting disconnections and arrange to send out an engineer.
    Great I thought this will be all be resolved, Engineer booked to come and investigate (I forget the date think it may have been towards the end of December I think its Ref REMOVED) my girlfriend took the day off work due as their was no weekend slot available she stayed in all day awaiting the engineer called BT three times whom say they would “deffinetly” be attending yet not one phone call or text from BT no engineer came.
    I phoned BT to see what had happened no explanation, a days wage lost due to BT
    I then booked the engineer to come out the 22nd January (Order No# REMOVED) this time the engineer came on time tested my line went to the cabinet and confirmed that there is a fault on the outside line and it would have to be replaced; the BT engineer said I will receive an update to what is happening next.
    Since then I have heard nothing from BT no phone calls, no emails no texts nothing!
    So I’m stranded with a slow Internet, a phone makes a “hissing noise” when in use which the engineer said was due to the faulty line, and whenever anyone makes / receives a call I get instantly disconnected.
    To top things off the Sainsburys voucher never arrived, I called BT whom submitted a request to get chased up a week later I received the voucher excellent!!! (25/01/14)
    My other half  went today to get some groceries for the week with the voucher only to be told by the till lady that the card is EMPTY! Nothing on it at all!
    I call BTs complaints contact number to wait 45 minutes before finally giving up.
    So here I am almost 2 months down the line paying BT full price for a service im not receiving.
    Can someone from a UK call centre that knows what they are doing please help me before I have a nervous breakdown, I cannot face speaking to someone who will “log my call” read from a script then never to return with an answer to what is going on?
    I have submitted this via the online “complaints” feature on the BT website over 2 weeks ago but never heard anything back.
    Please help.
    Rich

    Hi Rich_X
    Send us an email using the contact the mods link in my profile I can have this investigated further for you.
    Thanks
    Stuart
    BTCare Community Mod
    If we have asked you to email us with your details, please make sure you are logged in to the forum, otherwise you will not be able to see our ‘Contact Us’ link within our profiles.
    We are sorry that we are unable to deal with service/account queries via the private message(PM) function so please don't PM your account info, we need to deal with this via our email account :-)

  • Can someone give me ABAP Dialog program /ALV Step by Step hands on examples

    Can someone give me a document for ABAP Dialog programming(module pool) and ALV - but i need Step by Step example ,with sreenshots and explanations.
    In general any ABAP, STEP BY STEP hands on examples - Smartform, Sapscrips, Report, BDC will be highly appreciated.
    I only need hands on examples please - regular Abap courses does not work because they dont have examples.
    Please help ASAP.
    Bob
    Welcome to SCN - but please read the rules of engagement before posting
    Edited by: Rob Burbank on Jun 14, 2009 4:28 PM

    What temporary files are you talking about?

  • Can someone help me understand what the measurement em stands for?

    I have been running into the measurement em (or is it en) and I cannot find an explanation as to what it means. Can someone explain it to me with an example or two?
    Thank you
    Allen Macfalda

    Murray *ACP* wrote:
    It's a relative font metric.  1em means use the browser's default size, while .5em means use half the browser's default size.  The default size is usually 16px, unless changed by some other CSS on the site.
    Hi
    To add to whar Murray has written, the relative font metric actually comes from the size of the letter 'm'. This means that if you have a width of 20em it will be 20 times the width of the letter 'm' in your chosen font not the browsers default font, (thats the theory). Some older browsers may use the browsers default font, (NN4, I did say old!) or even a few current mobile browsers.
    It is also possible, (in a few modern browsers) to use en or ex for the mesurement, and these are based on the letter 'n' and 'x' respectively.
    PZ

  • Odd RV042 behavior can someone help shed some light?

    We have a group of 4 x RV042 routers linking the 3 branch offices back to the head office via VPN site to site tunnels. Also each of the sites has dual ISP connection, one from a cable provider and the other a DSL connection operating in smart link backup mode with tunnels configured for when each wan is active. In the past week one of the branch offices RV042 started failing over to the secondary DSL WAN link when the primary cable ISP WAN IP was expired and was being refreshed.
    The odd behavior starts a few hours after the switch over, the system log reports that the router restarted but with no error reported and it shows the date being December 31 2002 beginning with a System Up message then the firmware message which is at 1.3.12.19 and establishes a connection with the primary WAN at this point I can ping the public IP but I cannot connect to the router nor can the users at the branch browse the web or establish VPN connectivity to the main office. This condition persists until the router is physically powered down and back on at which time it shows the correct date and time and all operations work well for the day. I must note the behavior seems to only occur between 5am - 7am so I want to believe that this behavior is tied to the ISP IP lease cycle, but it only affects one branch office with all offices using identical ISP's, setup and configuration.
    Can someone help make sense of this situation as rebooting the router each day is becoming annoying?

    Hi Garth,
    Thank you for posting. I wish I had a brilliant explanation for you that would immediately solve the problem. Unfortunately I have not seen this before. There is a possibility that the configuration file is corrupt or has been changed inadvertently. I think I would set the router to factory defaults and manually reconfigure it. There is also the option of swapping the router for another. If the other router does the same thing it could point to an environmental issue. If this router does the same thing at the alternate location it could point to either a configuration or hardware issue.

  • Can someone explain to me what the Terminal does?

    Can someone explain to me what the Terminal application does? A good explanation would be greatly appreciated, thanks!
    NA

    Can someone explain to me what the Terminal
    application does? A good explanation would be greatly
    appreciated, thanks!
    Sure, go here:
    http://www.macdevcenter.com/pub/a/mac/2001/12/14/terminal_one.html
    Powermac G5 - Macbook C2D   Mac OS X (10.4.8)   Both macs are heavily upgraded and used frequently.

  • Can someone help with buying from international stores?

    Can someone please help? I am trying to get a program from U.S i tunes store and it won't let me because mine is in Aussie dollars.
    Any leads would be great.

    The issue of cross store purchasing comes up frequently so I'll just quote one of the most complete explanations (courtesy of Dave Sawyer) from the many given:
    The content owners do not allow cross-border sales from any of the legal download stores (not Apple or the proprietors of any of the other stores). You must therefore have legal residence in the country of the iTunes Store you wish to use. So in order to buy from another country's iTunes Store, you must (as proof of residence) have either:
    a) a credit card issued by a bank in that country with a billing address also in that country, or
    b) a mailing address for your residence in that country and a gift certificate or a prepaid card that was bought in that country.
    If you cannot fulfill one of these two sets of conditions, you will not be able to purchase from any given country's iTunes Store.
    This, again, is due to restrictions placed on Apple by the media companies and other copyright holders (who are often completely different from country to country and so all require their own individual negotiations and contracts), not by Apple's choice.

  • Can someone explain about frame header size in Ethernet over MPLS

    Can someone explain about frame header size in Ethernet over MPLS

    Hello Arun,
    Here is some explanation:
    http://cciethebeginning.wordpress.com/tag/eompls/
    Also I attached pcap file, you can open it in wireshark and look at entire packets. There are some pings 10.0.0.1 <-> 10.0.0.2 between CEs
    Best Regards
    Please rate all helpful posts and close solved questions

  • Can someone briefly explain what is SPAU and SPDD

    Hi All,
    I would like to have some clarity on SPAU and SPDD. Different sites show different explanations.
    Can someone briefly describe them?
    Thanks
    Vijay

    SPAU - The adjustment of Repository objects is carried out with transaction SPAU. Only those objects that have been modified by you and are being redelivered by SAP in an upgrade are presented for adjustment. If the objects you modified are not being delivered by SAP with the current upgrade, then they do not appear in the display.
    The system automatically recognizes during upgrade if modification adjustment is necessary. You are then prompted to perform the modification adjustment.
    You must decide whether the objects contained in the adjustment list should retain your modifications or if they should be reset to original. This is mandatory and must be carried out for each object visible in the adjustment transaction. Otherwise, the new original stays active in your System. The objects continue to be displayed in SPAU as not adjusted.
    SPDD - You need not perform adjustments with transaction SPDD if  you have made no changes whatsoever to the SAP standard objects of the ABAP Dictionary You have only added your own development work to the SAP System, that is new domains, data elements, or table structures in the customer namespace. Only changed SAP objects require further processing.
    For more details you may refer  below mentioned links.
    http://help.sap.com/saphelp_webas620/helpdata/en/c8/61ec66e33611d1954b0000e82de14a/frameset.htm
    http://help.sap.com/saphelp_webas620/helpdata/en/c8/61ec66e33611d1954b0000e82de14a/frameset.htm
    Hope this will help you.
    Best Regards,
    Sachin.

  • I have just downlaoded the color burst app, can someone explain how to use it?

    I have just downlaoded the color burst app, can someone explain how to use it??
    There is no help in the app and i can't log onto the smart solutions..it is really frustrating me because it is propably a really simple app...can someone please help???

    I posted in this thread an example that illustrates how to use the 3d graph to do surfaces ac lines.
    The type of data that you present to the 3d graph depends on which mthod you are using. In general you want to present a set of points that need plotted. These points are defined by taking one value for each of the XYZ and sometimes W arrays.
    Explanation:
    You want to plot a surface that is defined by four point (X0,Y0,Z0,W0), (X1,Y1,Z1,W1), etc. You can present the values using (4) 2-d arrays each of which have four values at index (o,o), (0,1), (1,0) and (1,1).
    Thie first point plotted would be the point that is defined by taking (0,0) from each of the arrays.
    So as you can see from the above all of your arrays should be of the same size and dimensions for this to work.
    Look at the Example i posted in the other thread and try some small experiments with small data sets before you jump to anything complicated.
    I hope that helps,
    Ben
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

  • Can someone point me to a small working example using wait()

    Or is wait() what I want to use?
    I need to have my app go to sleep for some period of time, say ten or fifteen minutes, and hide its window during that time. Then after that ten minutes it opens its window back up.
    I've looked all over Google and I can't find any code samples that a newbie could make sense of. Can anyone point me to a sample?
    I wrote what I thought, intuitively, was the way to do it, but I am getting some cryptic message on the "wait()" about "java.lang.IllegalMonitorStateException" which I looked up, but the "explanation" makes even less sense than the raw message. :(
      public void runLoop() {
        getPrefs();
        while (true) {
          ... do stuff ...
          try {
            wait(1000*timeOut);
          } catch ( InterruptedException ie )  {
            ... do stuff ...
      }thanks for any guidance.
    --gary                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    Can someone PLEASE point me to a working example?
    I use Java only very rarely, and only when forced to, and I am not an expert. Frankly, in spite of being expert in a dozen other languages I am COMPLETELY INCOMPETENT in Java. I'm just trying to get this project done and out of my hair so I can safely forget all about Java for the next year or two. I'd give the project to someone else, but every other coder in the shop refuses to go anywhere near Java.
    If I can get this one thing working I can call the project done and be out of here.
    I have a working ap that just needs to close its own window when a button is clicked, for some (user specified) period of time like 10 or 15 minutes, and then reopen its window after that period of time. It is intuitively obvious that I should be able to use timer methods, or sleep() , or wait(), but I have not been able to get any of those to work, and the error messages are more cryptic than ancient Sumerian cuneiform.
    I've Googled for a working example, but haven't found anything that I can figure out. The examples I've found presuppose far more expertise than I posses, and have far too many pieces missing. Can anyone just point me to a complete example of an ap that sleeps for some period of time and then wakes up again?
    I would really, really appreciate the help, and once I've finished this project I promise I won't ever bother you again. Really.
    --gary                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

Maybe you are looking for

  • How to move xmlElement to Footnote

    Hi All, I have tried this var tmpfootnote=footnoteref[fref].insertionPoints.item(-1).footnotes.add(); footnotetext[fele].texts[0].move(LocationOptions.after, tmpfootnote.insertionPoints[tmpfootnote.insertionPoints.length-1]); This code will move only

  • Default selection on programmatically created UIPickerView

    I'm learning Obj-C for iOS 4 apps. This's what I've done so far... Created a TextField. At 'textFieldShouldBeginEditing' event, I'm creating a dynamic PickerView with my entries, and returning NO to skip the default keyboard. I've also made my UIView

  • Composite clients:  include command button inside data table

    Directly placing the command button into the datatable does work. However, I'd like to move it outside to another file and then include it. What's the best approach, to use ui:include? Is there a better approach? I'd like to have datatable.xhmtl and

  • Final cut x won't open

    HI all, IM having trouble with my final cut x. I was importing my media into final cut then all of the sudden the power search that my Mac was plugged in went off. SHutting down my computer while it was importing the media. AFter that when I launch F

  • Is there anyway i can save it as a webpage

    Hi i made a website layout in photoshop. is there anyway i can save it as a webpage or something, either with Photoshop or ImageReady?