Difference between compare nad compareTo method

difference between compare nad compareTo method

compareTo is a method of the Comparable interface; it takes one argument and compares the current object to that argument; it provides a default ordering of the objects of this class
compare is a method of the Comparator interface; it takes two arguments and compares them; it is used to provide an external ordering, either for things that don't already have an ordering, or to provide a different ordering than the one they already have

Similar Messages

  • What's the difference between equals() and compareTo() method

    I'm confused between the two method from String class ,,, what's the main difference between equals() and compareTo() method?

    API docs give quite clear information IMHO
    public boolean equals(Object anObject)
    Compares this string to the specified object. The result is true if and only if the argument is not null and is
    a String object that represents the same sequence of characters as this object.
    public int compareTo(String anotherString)
    Compares two strings lexicographically. ....
    The result is a negative integer if this String object lexicographically precedes the argument string. The
    result is a positive integer if this String object lexicographically follows the argument string. The result is
    zero if the strings are equal; compareTo returns 0 exactly when the equals(Object) method would return
    true. Mike

  • Whats the difference between comparable and comparator?

    whats the difference between comparable and comparator?
    when must i use comparable, and when must i use comparator?

    whats the difference between comparable and
    comparator?Comparable is from the java.lang package, Comparator from java.util.
    when must i use comparable, and when must i use
    comparator?Here's a tutorial on both:
    http://java.sun.com/docs/books/tutorial/collections/interfaces/order.html

  • Difference between Function Module Vs Method in Class Module

    1) Can you please tell the difference between the Function module used in abap program and the method of the class module used in abap programming.
    2) does it necessary to do commit statement after calling the function module.
    Thankyou for you time.
    Bhaskar.

    Hi,
    1)
    Check this difference..
    The main difference between real object orientation and function groups is that although a program can work with the instances of several function groups at the same time, it cannot work with several instances of a single function group. Suppose a program wanted to use several independent counters, or process several orders at the same time. In this case, you would have to adapt the function group to include instance administration, for example, by using numbers to differentiate between the instances.
    2) COMMIT WORK is required for BAPI..And not required when you normally call a function module..Unless required ..
    Example
    Update function modules requires COMMIT WORK to execute the function module.
    Thanks,
    Naren

  • Difference between F , C , L methods of printing

    Hi ,
    Can someone help me in understanding the core and simple difference between these access methods .
    For me c and l looks same .. so thats why little confused .
    Please help .

    Harsh,
    C---- Local printing from a <u><b>Microsoft Windows NT or Microsoft Windows 2000 system or from AS/400 and OS/390.</b></u>
    L -
      Local printing from a <u><b>UNIX system</b></u>
    Hope you got it,
    Thanks
    Kalyan
    plz reward if answer if helpful

  • Difference between decode nad replace

    can you plz highlight the difference between decode and replace.. am using oracle10g r2 on solaris....
    these r the 2 quereies...
    select count(DECODE(EMAIL_L,'%@yahoo.com%','%@thoyahoo.com%')) FROM SIEBEL.MAIL
    i understand here if EMAIL_L is like @yahoo.com then it returns @thoyahoo.com
    select count(REPLACE(EMAIL_L,'%@yahoo.com%','%@thoyahoo.com%')) FROM SIEBEL.MAIL
    and here also if EMAIL_L has @yahoo.com then it returns @thoyahoo.com
    But when i try and execute each of them i dont get any output in the decode query....
    Any explainations???

    decode and literals match the exact literals within column not part of string
    SQL> select ename,decode(ename,'MI','IM') from emp
      2  /
    ENAME      DE
    SMITH
    ALLEN
    WARD
    JONES
    MARTIN
    BLAKE
    CLARK
    SCOTT
    KING
    TURNER
    ADAMS
    ENAME      DE
    JAMES
    FORD
    MILLER
    14 rows selected.
    SQL> select ename,decode(ename,'MILLER','MILLIONAIRE') from emp
      2  /
    ENAME      DECODE(ENAM
    SMITH
    ALLEN
    WARD
    JONES
    MARTIN
    BLAKE
    CLARK
    SCOTT
    KING
    TURNER
    ADAMS
    ENAME      DECODE(ENAM
    JAMES
    FORD
    MILLER     MILLIONAIRE
    14 rows selected.Khurram

  • Differences between various sshd restart methods?

    As far as I can see there are some restart methods of the sshd server (in Solaris Express):
    svcadm restart ssh
    and
    /lib/svc/method/sshd restart
    What are the differences?
    Peter

    cat sshd
    # This script is being used for two purposes: as part of an SMF
    # start/stop/refresh method, and as a sysidconfig(1M)/sys-unconfig(1M)
    # application.
    alan

  • What is the difference between these deep sleep methods?

    I have found two ways to put the MBP into "Deep Sleep"/Hibernation but I am not sure what the difference is. Could you help me?
    http://www.apple.com/downloads/dashboard/status/deepsleep.html
    http://www.apple.com/pro/tips/quicksleep.html
    Is the latter even Hibernation? Thanks for any help.

    Homework question?
    The answer is on this page (Step 5)
    http://java.sun.com/products/jsp/syntax/1.2/syntaxref1217.html#8865

  • Difference between Error Status in Method Exception

    Hi all!
    There are three checkboxes under 'Exceptions' for each method in a Business Object. They are Temporary Error, Application Error and System Error. Could anyone please tell me when are we supposed what type and why?
    Also, is this true that if we use Temporary Error then the particular Step in the workflow (that calls the method with exception) will remain "in process"? In that case, should be use Application Error/System Error?
    Thanks in advance!
    MA

    Hmmmm. So you don't want to do anything and let us do the work? But ok I'll help you out. Search this forum and look in the results for a question by Hari about the same problem.
    I could find it pretty quick, so I guess so should you.
    Regards,
    Martin

  • Interested in Performance Difference Between Different SL Install Methods?

    Go here: http://discussions.apple.com/thread.jspa?messageID=10077299&#10077299.

    Run a benchmark for your specific case??
    Yes. If you are to implement such an operation, try both, using your actual data, and see which performs best. I can't speak to this particular case, but very often to performance questions is
    it depends. So the only way to find out when you are interested for a specific case is to test. And keep in mind that next time it could be different.
    Erland Sommarskog, SQL Server MVP, [email protected]

  • Difference between All valuation methods

    Hiii Guru's,
                       Can anybody tell me the actual difference between the inventory valuation methods given in B1 - Standard / Moving / FIFO ... Actually I want to know their impact in each case if I maintain my masters at item group level. so how  it will affect my accounts... preferrably give examples in each case to understand the different scenario...
    Thanks in advance. I will assign points for helpful asnwers.
    Regards,
    Abhishek

    Hi,
    Standard :-
    This valuation method means the cost of an item will be standard. It never change under any circumstanses. The Only way to change the cost is to Inventory Revaluation.
    Eg, Lets consider Item A
    Valuation Method : Standard
    Value : $56.00
    The above value will be taken to any calculation.
    Moving Average :-
    This means a valuation takes place based on the corresponding quantities and prices for each goods receipt and issue, and the moving average price is updated accordingly. The valuation price is calculated as the quantity multiplied by the average price.
    Eg, Let's Consider Item A
    Valuation Method : Moving Average
    Value : $56.00
    If we purchase the item for $60.00 then the item cost will be changed according to the purchase value. In this Moving Average Value will be th item cost.
    FIFO :-
    Under this valuation method, the system assumes that the items that entered the warehouse first will also exit first. This means goods issues are valuated with the prices that are valid for the first goods receipts.
    Eg., Let's consider Item A,
    Valuation Method : FIFO
    Value : $56.00
    The current value of the item is $56.00. If we purchase the item for $60.00 then the item will have two values, ie., items which bought first with $56 and currently bought with $60.00. The item issue will be done in FIFO manner. (ie., items with $56.00 value will be issued first and then stock with $60.00 will be taken)
    Raja.S

  • What is the difference between these setter methods

    What is the difference between these two setter methods??
    <jsp:useBean id="checking" scope="session" class="bank.Checking" />
    <jsp:setProperty name="checking" property="balance" value="0.0" /> and
    <jsp:useBean id="checking" scope="session" class="bank.Checking" >
    <jsp:setProperty name="checking" property="balance" value="0.0" />
    </jsp:useBean>

    Homework question?
    The answer is on this page (Step 5)
    http://java.sun.com/products/jsp/syntax/1.2/syntaxref1217.html#8865

  • Main difference between these 2 methods

    HI
    what is the main difference between updateOrder and repriceOrder methods in any form handler
    please give me exact difference

    Both are totally different operations. repriceOrder method invokes the pricing engines and calculators to calculate the order prices whereas, updateOrder method saves the changed order properties to the database.
    Thanks,
    Tejas

  • Difference between Reboot and Power OFF/ON

    Hi Community,
    in a forum a User is reporting serious problems after an update to the actual major release 10.6.5. He said if he boot the system in safe mode everything works as expected, after a reboot the same but after a power off and on again, the system is freezing after the login.
    Now I'm searching for the difference between this two start methods, maybe we can isolate the problem a bit easier.
    Thx & Bye Tom

    Allan Eckert wrote:
    If the operating system is running when the power button is used to stop the computer, this can do great harm to the disk by not allowing all of the data to be written to disk as it should be.
    Yes I agree but this wasn't what I'm asking for. The question is why the system works fine as long as the User proceed a normal reboot and why it is broke after a shutdown. I don't believe that the User enforce a dirty shutdown after he boot the system in safe mode. But sure, if he boot the system after a shutdown, and the system is freezing, than he have to proceed a dirty shutdown. What else could he do?
    Thx & Bye Tom

  • Difference between  methodName(a,b) and a.methodName(b)

    I've written the 2 following methods:
    public boolean equals (Object o)
    if (this==o) return true;
    if (!(o instanceof Point)) return false;
    Point p= (Point) o;
    return (this.getX()== p.getX()) && (this.getY()== p.getY());
    public static boolean equals (Object o1, Object o2)
    if (o1==o2) return true;
    if ((!(o1 instanceof Point)) || (!(o2 instanceof Point))) return false;
    Point p1= (Point) o1;
    Point p2= (Point) o2;
    return (p1.getX()== p2.getX()) && (p1.getY()== p2.getY());
    Both seem to work the same. Why do i have to declare the second one as static?
    Which is the difference between them? "clone" method is just an example. This question applies in general for methodName(a,b) and a.methodName(b).
    Thanks

    For static, see
    http://www.martinrinehart.com, Articles, What Is Static?
    jverd is right, the first is more OO. But in SmallTalk you pass the message "+2" to a "2" object if you want to get 4. Very OO and just plain dumb.
    Before the word "pattern" was applied to these things, every programmer built a personal library of useful routines to call as needed. If you work with Points, that static routine should be part of your library.
    By the way, the O1==O2 check isn't needed. It will save a microsecond if it's true, but you should code like a backpacker packs: when in doubt, leave it out.

Maybe you are looking for

  • Creating XML file from Java Bean

    Hi Are there any standard methods in Java 1.5 to create XML file from java bean, i can use JAXB or castor to do so, But i would like to know if there is any thing in java core classes, I have seen XMLEncoder, but this is not what i want. Any ideas As

  • My ipod touch says disabled connect to itunes but i tunes does not recognize the ipod.

    I don't know what to do and itunes is not reading my ipod. I already updated itunes.

  • 160G iPod classic Will NOT restore

    160G iPod classic Will NOT restore Timeline: 1. iPod freezes 2. restart 3. everything gone from device_ creating appearance of factory settings having been restored. 4. plug into computer. 5. computer says it cannot recognize iPod because formatless

  • Using Checkboxes in spry:detailregion

    I like the visual effect and ease of use that checkboxes in a multiple select box provide. Example code for what I mean is below (this css is for Firefox by the way, it renders uglier in IE but I use another css for that anyway):

  • English Dictionary for 6300

    What's the maximum limit of java app for nokia 6300? My 6mb file of Oxford dictionary won't work.. [url=http://www.xanax2mg.com]buy xanax online[/url]