Difference between Object equals() method and ==

Hi,
Any one help me to clarify my confusion.
stud s=new stud();
stud s1=new stud();
System.out.println("Equals======>"+s.equals(s1));
System.out.println("== --------->"+(s==s1));
Result:
Equals ======> false
== ------------> false
Can you please explain what is the difference between equals method in Object class and == operator.
In which situation we use Object equals() method and == operator.
Regards,
Saravanan.K

corlettk wrote:
I'm not sure, but I suspect that the later Java compilers might actually generate the same byte code for both versions, i.e. I suspect the compiler has gotten smart enough to devine that && other!=null is a no-op and ignore it... Please could could someone who understands bytecode confirm or repudiate my guess?Don't need deep understanding of bytecode
Without !=null
C:>javap -v SomeClass
Compiled from "SomeClass.java"
class SomeClass extends java.lang.Object
  SourceFile: "SomeClass.java"
  minor version: 0
  major version: 49
  Constant pool:
const #1 = Method       #4.#15; //  java/lang/Object."<init>":()V
const #2 = class        #16;    //  SomeClass
const #3 = Field        #2.#17; //  SomeClass.field:Ljava/lang/Object;
const #4 = class        #18;    //  java/lang/Object
const #5 = Asciz        field;
const #6 = Asciz        Ljava/lang/Object;;
const #7 = Asciz        <init>;
const #8 = Asciz        ()V;
const #9 = Asciz        Code;
const #10 = Asciz       LineNumberTable;
const #11 = Asciz       equals;
const #12 = Asciz       (Ljava/lang/Object;)Z;
const #13 = Asciz       SourceFile;
const #14 = Asciz       SomeClass.java;
const #15 = NameAndType #7:#8;//  "<init>":()V
const #16 = Asciz       SomeClass;
const #17 = NameAndType #5:#6;//  field:Ljava/lang/Object;
const #18 = Asciz       java/lang/Object;
SomeClass();
  Code:
   Stack=1, Locals=1, Args_size=1
   0:   aload_0
   1:   invokespecial   #1; //Method java/lang/Object."<init>":()V
   4:   return
  LineNumberTable:
   line 1: 0
public boolean equals(java.lang.Object);
  Code:
   Stack=2, Locals=2, Args_size=2
   0:   aload_1
   1:   instanceof      #2; //class SomeClass
   4:   ifeq    25
   7:   aload_1
   8:   checkcast       #2; //class SomeClass
   11:  getfield        #3; //Field field:Ljava/lang/Object;
   14:  aload_0
   15:  getfield        #3; //Field field:Ljava/lang/Object;
   18:  if_acmpne       25
   21:  iconst_1
   22:  goto    26
   25:  iconst_0
   26:  ireturn
  LineNumberTable:
   line 6: 0
}With !=null
C:>javap -v SomeClass
Compiled from "SomeClass.java"
class SomeClass extends java.lang.Object
  SourceFile: "SomeClass.java"
  minor version: 0
  major version: 49
  Constant pool:
const #1 = Method       #4.#15; //  java/lang/Object."<init>":()V
const #2 = class        #16;    //  SomeClass
const #3 = Field        #2.#17; //  SomeClass.field:Ljava/lang/Object;
const #4 = class        #18;    //  java/lang/Object
const #5 = Asciz        field;
const #6 = Asciz        Ljava/lang/Object;;
const #7 = Asciz        <init>;
const #8 = Asciz        ()V;
const #9 = Asciz        Code;
const #10 = Asciz       LineNumberTable;
const #11 = Asciz       equals;
const #12 = Asciz       (Ljava/lang/Object;)Z;
const #13 = Asciz       SourceFile;
const #14 = Asciz       SomeClass.java;
const #15 = NameAndType #7:#8;//  "<init>":()V
const #16 = Asciz       SomeClass;
const #17 = NameAndType #5:#6;//  field:Ljava/lang/Object;
const #18 = Asciz       java/lang/Object;
SomeClass();
  Code:
   Stack=1, Locals=1, Args_size=1
   0:   aload_0
   1:   invokespecial   #1; //Method java/lang/Object."<init>":()V
   4:   return
  LineNumberTable:
   line 1: 0
public boolean equals(java.lang.Object);
  Code:
   Stack=2, Locals=2, Args_size=2
   0:   aload_1
   1:   instanceof      #2; //class SomeClass
   4:   ifeq    29
   7:   aload_1
   8:   ifnull  29
   11:  aload_1
   12:  checkcast       #2; //class SomeClass
   15:  getfield        #3; //Field field:Ljava/lang/Object;
   18:  aload_0
   19:  getfield        #3; //Field field:Ljava/lang/Object;
   22:  if_acmpne       29
   25:  iconst_1
   26:  goto    30
   29:  iconst_0
   30:  ireturn
  LineNumberTable:
   line 6: 0
}

Similar Messages

  • What is the difference between organisation payment method and Assignment payment method?

    What is the difference between organisation payment method and Assignment payment method?
    As i am a new bie, i am curious to know this though it might sound a silly question.
    Thank you,
    Kuton

    You can create an Organization payment method of any Payment type(Cash, Check, BACS, NACHA etc) under the same country.
    All these will be valid payment methods on the payroll description form.
    And you can even attach these to a person.
    In which case you will have a Base currency (say USD) and payment currency (say GBP).
    These cases are not normal and only used by people who use a single BG for paying employees in 3-4 countries.
    So, unless you need to pay in different currencies, do not use it.
    Cheers,
    Vignesh

  • Difference between batch input method and batch input recording in LSMW?

    hi,
    plz tell me the difference between batch input method and batch input recording in LSMW?
    thanks & regards
    Ruban

    Hi Ruban,
               The main difference between the two is in lsmw we can view the code status at any time just by coming to prvious steps, but whereas in batch input method unless the recording is finished we cant view the code.
    second diff is tht we need to do lot of coding in batch inptu whereas here in lsmw we need not do much coding and mapping to data.
    third diff is that batch input is both inbound and outbound where as lsmw is only inbound.
    hope u got the differences.....
    Regards,
    sana M...

  • Difference between batch input method and direct input method in LSMW.

    Hi all,
    what is difference between batch input method and direct input method in LSMW. are they same?if differences are there tell me with details?

    Hi,
    Here are few differences bw Batch Input and Direct Inputs methods.
    Batch Input: Uses classical BDC approach, but doesn't required an ABAP program to be written to format the BDC DATA. The user has to format the data using predefined structures and store it in a flat file. Yet it is a slower updation method.
    Direct Input: Works similar to Batch Input programs. The difference is, instead of processing screens they validate fields and directly load the data into tables using standard function modules. Much faster and suits for large volume of data.
    Thanks.
    DhanaLakshmi M S

  • [Qualif.] Difference between object type 'Q' and infotype 0024

    Hi,
    For the xRPM 4.0 solution, we need to maintain skills for resources. There is a HCM integration functionality to import skills from a HR system to Business Partners (which - basically - represent users that can be staffed on a project in the xRPM solution).
    Today, there is no skill management in our HR system.
    There are 2 notions that look very similar to me :
    - <b>Infotype 0024</b> [Transaction PA20/PA30] : contains Qualifications of a user in PA (Personal Adminsitration) with the standard table T574A holding the possible values
    - <b>Organizational Structure</b> (HRP1000/HRP1001) [transaction BP / PP* ?]: with the objects Qualifications 'Q' and Qualifications Group 'QK'
    It seems taht the integration operates on the Organizational Structure. But we would like to assess both solutions.
    <b>What is the difference (pros&cons) between the 2 of them ?</b>
    Thanks in advance.
    Best regards,
    Guillaume
    Message was edited by:
            Guillaume GARCIA

    To be precise, the way Infotype 24 behaves depends on whether integration between PA and PD is active.  This is controlled by setting PLOGI QUALI in table T77S0.  There are also other settings in this table that affect how quals work in an integrated scenario, you will find these in the QUALI XXXX section.
    If integration is active, the qualifications are maintained in a catalogue via transaction OOQA.  What you see in IT0024 are the object Q <--> P relationships as mentioned above once a qualification object has been assigned to the employee.  This option has the advantages of being able to use the integrated objects in othe modules e.g. as prerequisites or imparted quals in the training module, skills/requirements matchup etc.  The down side is that being PD objects, these are more difficult to report with SAP Query or Adhoc Query tools, but there are ways of doing it.
    If integration is not active, the data is simple stored in PA table PA0024 and the quals themselves are set up via the IMG.  The data really can't be used in any other module, but the reporting aspects are much easier with the standard query tools.
    Regards,
    John

  • Difference between calling static method and not static method?

    Hi,
    Suppose i want to write a util method, and many class might call this method. what is better? writing the method as static method or not static method. what is the difference. what is the advantace in what case?

    writing the method as static method or not static
    method. what is the difference.The difference is the one between static and non-static. Any tutorial or the JLs will clarify the difference, no need to repeat it here.
    what is the advantace in what case?It's usually not like you have much of a choice. If you need access to an instance's attributes, you can't make it static. Otherwise, make it static.

  • Whats the difference between a class method and a instance method.

    I have a quiz pretty soon and one of the questions will be: "How does an instance method differ from a class method." I've tried looking this up but they gave me really complicated explanations. I know what a instance method is but not really sure what a class one is. Can someone post an example of a class method and try to explain what makes it so special?
    Edited by: tetris on Jan 30, 2008 10:45 PM

    Just have a look:
    http://forum.java.sun.com/thread.jspa?threadID=603042&messageID=3246191

  • Differences Between Object And System Privileges

    Hi,
    Whats the difference between object and system privileges in oracle?
    Cheers
    Paul

    System Privileges
    A system privilege is the right to perform a particular action, or to perform an action on any schema objects of a particular type. For example, the privileges to create tablespaces and to delete the rows of any table in a database are system privileges.
    Schema Object Privileges
    A schema object privilege is a privilege or right to perform a particular action on a specific schema object:
    For example, the privilege to delete rows from the departments table is an object privilege.
    Some schema objects, such as clusters, indexes, triggers, and database links, do not have associated object privileges. Their use is controlled with system privileges. For example, to alter a cluster, a user must own the cluster or have the ALTER ANY CLUSTER system privilege.
    A schema object and its synonym are equivalent with respect to privileges. That is, the object privileges granted for a table, view, sequence, procedure, function, or package apply whether referencing the base object by name or using a synonym.
    Granting object privileges on a table, view, sequence, procedure, function, or package to a synonym for the object has the same effect as if no synonym were used. When a synonym is dropped, all grants for the underlying schema object remain in effect, even if the privileges were granted by specifying the dropped synonym.

  • Differences between object and object references

    What's the differences between object and object references? To me, it seems the same, but I am sure there are differences.
    Student s = new Student("Joe",20);
    s is an object of class Student. Can we say s is an object reference of class Student?
    Please clarify. thanks!!

    Student s = new Student("Joe",20);
    s is an object of class Student. Can we say s is an
    object reference of class Student?The thing you created via "new Student()" is an object. The variable you declared via "Student s" contains a reference to that object. People say all kinds of things but I find it clearer to differentiate between variables and the objects they refer to.

  • Difference between system level privilege and object level privilege

    hi
    i just want to know the difference between system level privileges and object level privilege.
    please correct me if i am wrong
    with system level privilege user can create objects such as creating tables,view,synonyms etc
    where as in object privilege we can only manipulate operations on object i.e perform dml not ddl
    please help

    Hi,
    810345 wrote:
    hi
    i just want to know the difference between system level privileges and object level privilege.
    please correct me if i am wrong
    with system level privilege user can create objects such as creating tables,view,synonyms etc
    where as in object privilege we can only manipulate operations on object i.e perform dml not ddl There are some system privileges that only concern manipulating objects: SELECT ANY TABLE, for example.
    The main difference is that the system-level privileges tend to cover all objects of a certain type, including objects that haven't been created yet.
    Object-level privileges usually apply only to one specifi object, such as one particular table, and are lost if the object is dropped. (For example, if I create a table called table_x, give you SELECT pivileges on it, then you can query my table. But if I then drop table_x and re-create it, you will not be able to see it unless I grant the privilege again.)

  • Difference between invoking a method using reflect.proxy and reflect.Method

    Could any one tell me the difference between invoking a method using reflection java.lang.reflect.Method and java.lang.reflect.Proxy
    using both the class, we can invoke a method at runtime
    1)
    Method mthd=cl.getMethod("methodName",parameterName);
    Integer output=(Integer)mthd.invoke(new RunMthdRef(),input);
    2)
    Proxy.newProxyInstance(super.getClass().getClassLoader(), new Class[] { adapter }, new SomeClass(this));
    Does anybody have any idea?

    The two idioms are fundamentally different. Using java.lang.reflect.Method is how we call a method on a class, using Proxy is how we intercept that method call. An exercise for you, to illustrate that they do not do the same thing: write a simple class with one method, then use java.lang.reflect.Method to invoke that method, and then use a Proxy to invoke that method

  • What's the difference between an audio INPUT and AUX object?

    Can someone explain the difference between an audio INPUT and AUX object? They both seems to do pretty much the same thing ... when would you use 1 over the other?

    revDave:
    Suppose you're recording a guitar track and you want to add a very gentle compressor to avoid overload during the rec process. you need an audio input channel with a compressor inserted. this way, your guitar will be recorded with the compressor processed. If you use audio and midi gear and want to bounce your material, put all your midi audio in an audio input channel.This way, you don't have to use a real audio channel to record them. You can hear them, even use some plugins, and have them bounced with your audio channels.
    Now, suppose you recorded three vocal channels, and want to use an equalizer. You need an aux object to send your vocal channels and use only one eq. This is very useful when you have similar materials recorded in diferent channels (2 guitars, vocals, pete/sax/bone, and so on). Send their outs to an aux object, insert the fx you want, and set the aux object's out to the main out of your project, and it's done.
    I hope it helps you.
    Tovinho

  • Difference between CR Server XI and Business Objects  Enterprise

    Can anybody just tell me in brief what is the Difference between CR Server XI and Business Objects  Enterprise?

    Here's the brief summary:
    CR Server is essentially Business Objects Enterprise with the following limitations:
    - Limited to a single server (no clustering)
    - Limited to a maximum of 4 CPUs
    - Limited to the Crystal Reports content type
    - Limited to a maximum of 20 Concurrent Users (or CAL - Concurrent Access License)
    - One CAL can service between 5 and 10 'real people' depending on your usage patterns.
    - No Web Intelligence
    - No Crystal Xcelsius
    - No Dashboarding
    - No Enterprise Performance Management
    - No Data Integrator
    It is ideal for a departmental or a small company reporting server.  It includes
    - CAL licensing (BusinessObjects Enterprise doesn't)
    - One copy of CR Developer Edition for every 5 CAL purchased (Report designers are extra with BusinessObjects Enterprise)
    - Live Office for office integration
    - Sharepoint 2003 Portal Integration Kit
    - Web based report administration and consumption
    - Business Views Manager for semantic layer maintenance
    I hope this helps - let me know if you have more questions.
    Thanks,
    Blair Wheadon
    Crystal Reports Product Management

  • What is the difference between on new focus and do prepare out put methods

    Hi,
    what is the difference between on new focus and do prepare out put methods.

    Hi Divya,
    DO_PREPARE_OUTPUT method is triggered each time the view is prepared after each event. Normally we redefine this method in order default the initial values based upon the parameter iv_first_time = 'X'. There can be certain other scenarios like putting data validations where this method can be helpful.
    For details on ON_NEW_FOCUS, refer to this [thread|on_new_focus event;
    Thanks
    Vishal

  • Cost difference between PM report MCI8 and IW38 orders cost

    Hi Experts!
    I have an issue of cost difference  between Plant Maintenance total actual cost of orders and Cost analysis report.
    Short Text    
    Cost difference between PM report MCI8 and IW38 orders cost   
    Long Text    
    Applied SAP notes 180047 and 112841 for the following error:
    Cost is not displaying in MCI8 for every 3 months intervals.
    Now this problem has been resolved but got an another error like cost
    difference between MCI8 report and IW38 order costs.
    Note applied method:-
    1). Configured FYV as Z1 with Period update for info structures S61 to
    S65, S70, S114 to S116.
    2). Regenerate order cost in Tcode OLI5.
    3). PMIS: Statistical setup of info structures T.Code u2013 OLPM
    For Info Structures which is changed in the configuration SO61-SO65,
    SO70, S114-S116.
    4). Copy info structures Version &( to Active version 000 T.Code u2013 OLIX,
    Select Copy version
    For all info Structure SO61-SO65, SO70, S114-S116.
    *Steps for Reconstruction*    
    New another error like cost difference between MCI8 report and IW38
    order costs.
    Step 1. Transaction- MCI8, Order type - CORR, Period -01.2009 to
    12.2009 and execute
    Step 2. Drilldown the corrective maintenance order costs into period
    wise.
    Step 3. Transaction- IW38, Order type Corr, Period -01.2009 to 12.2009,
    Currency - EUR and execute
    Cost differences: E.g. Example A)
                                   MCI8                                 IW38
    Total costs             8.041,69                           5.544,99
    of WOs               18                                     18
    So far my view is that, regardless of the selection criteria or the
    output layout, predominantly the costs are different.
    I would expect that they are equal. And what the right result are,..u2026Iu2019m
    not sure.
    Regards,
    Santhamoorthy

    Hello,
    Sometimes this difference comes because of the selection period which we are choosing.
    Try to run IW38 once with the help of Basic start and basic finish dates of the order.
    And after that with the help of the period with the same dates range.
    You will get the difference also.
    the reason is that whenever any Posting is done in the previous month PM order the system changes the basic start date and when you select the current period and execute IW38 it shows the whole cost incurred on the order including all previous cost.
    But in MCI8 it does not happen because MCI8 is run through LIS structures. And in this report only the current month cost will be shown by the system.
    I hope you got the idea about differences.
    Regards
    Naveen

Maybe you are looking for

  • How to convert java .class file to .dll file

    hi, I got a problem, I have to convert my java .class file to .dll file. Microsoft VC++ program will invoke the converted .dll file. Is there any other possibility. I was confused. Cam any body help me. If you are having solution for the can you send

  • Can windows xp use a different sound card for itunes - I want to use a sound card for itunes and another for all other apps

    Can Windows XP use a different sound card for itunes - I want to use a sound card for itunes and another for all ther apps

  • Using Beans First time...

    I'm relatively new to JSP. This is basically the error I recieve using latest Tomcat... : cannot resolve symbol symbol : class Wallet location: class org.apache.jsp.Wallet_jsp Wallet foo = null; Wallet.class is in myApp/WEB-INF/classes/Wallet.class T

  • New Photo Folders for Ipod Touch

    How do I make new folders for certain photo groups for my Ipod Touch.I have folders already made up on my computer with the photos I want in them,but when I go to upload them on my touch,it puts all my photos under photo library.I know you can make n

  • IPhone Upgrade Eligibility Question

    My old iPhone 3G has finally died (a collision accident that popped the screen and forced it into white screen mode. I have no way of fixing this, and if there is a solution involving the home and sleep buttons, I have no luck because the latter butt