What would be the result if we overrode the equals method properly

import java.util.*;
class Nearly{
   String value:
   Nearly(String v){ value = v;}
   public int hashCode(){ return 1;}
   public boolean equals(Nearly n){
   if(value.charAt(0) == n.value.charAt(0)) return true;
   return false;
   public static void mian(String [] sss){
     Nearly n1 = new Nearly("aaa");
     Nearly n2 = new Nearly("aaa");
     String s = "_";
     if(n1.equals(n2)) s += "1";
     if(n1==n2) s += "2";
     Set <Nearly> set = new HashSet <Nearly>();
      set.add(n1);
      set.add(n2);
     System.out.println(s + " " + set.size());
}Ans: b) -1 2
Reason: Two different equals() methods are invoked, because the equals() method shown in the code doesn't properly override Object.equals(), which takes an Object
Ok so what would have been the result if the equals() method was something like this:
public boolean equals(Object n)
{I guess my question is about the overriding the equals() method which i am not able to understand

pksingh79 wrote:
what would be the result if we overrode the equals method properlyThe result would be a method, the functionality of which would adhere to Object#equals()'s contract:
public boolean equals(Object obj)
Indicates whether some other object is "equal to" this one.
The equals method implements an equivalence relation on non-null object references:
&#42; It is reflexive: for any non-null reference value x, x.equals(x) should return true.
&#42; It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and
only if y.equals(x) returns true.
&#42; It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and
y.equals(z) returns true, then x.equals(z) should return true.
&#42; It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y)
consistently return true or consistently return false, provided no information used in equals
comparisons on the objects is modified.
&#42; For any non-null reference value x, x.equals(null) should return false.

Similar Messages

  • I have one specific library that when I select the "view all clips" in the browser drop down box, FCPX locks up.  Rebuild the library?  What would be the best method?

    Final Cut Pro locking up when view all clips selected in the browser.

    Russ H,
    Yes, Force quit is the only option.  No background tasks running, nothing on FCPX works, save I can move the beach ball around.
    All the other menu options work fine.  In fact, FCPX works in the library except when I select view all clips in the browser.
    I am running Version 10.1.3 .  It is only this library that has the problem.  I am a new user so I only have three or four libraries so far.  Most on the same local external drive.
    The only difference I have been able to determine is the library in question has files on my boot drive as well as the local external.  Could that be the issue?
    Thanks for the prompt reply!

  • HT3231 how do i   TRANSFER MY PHOTOS AND VIDEOS FROM MY MAC PRO POWERBOOK G4 TO MY NEW MACBOOK PRO,  WHAT WOULD BE THE BEST WAY,  THANKS

    I HAVE A MAC POWERBOOK G4 AND WOULD LIKE TO TRANSFER MY FILES, PHOTOS AND VIDS TO MY NEW MAC PRO,  WHAT WOULD BE THE BEST METHOD??  THANKS ROB

    I think the easiest way is to use a firewire cable (you will need on like this: http://www.google.com/products/catalog?q=Firewire+400+to+800+cable&oe=utf-8&rls= org.mozilla:en-US:official&client=firefox-a&um=1&ie=UTF-8&tbm=shop&cid=120962573 04625337030&sa=X&ei=PytQT9r4NtOBsgL9s_C6Dg&ved=0CHYQ8gIwAA).
    Power up the Power Mac G4 and hold the "T" key while it is booting (this puts the G4 notebook in Firewire Target Disk mode).  Connect the G4 notebook to the newer MacBook Pro and use the Migration assistant (/Applications/Utilities) OR browse through the files and copy what you want.

  • BSM Auditing - what would be the Audit_id ?

    Hi all,
    Please tell me what would be the audit_id in the following scenario.
    I have two nodes, say Node1 and Node2
    On Node1_
    I have created a role called “*audit_role*”
    I have assigned “audit_role” to user called “test” on Node1.
    These are the contents of the /etc/user_attr
    root::::auths=solaris.*,solaris.grant;profiles=Web Console Management,All;lock_after_retries=no;min_label=admin_low;clearance=admin_high
    audit_role::::type=role;defaultpriv=basic,dtrace_kernel,dtrace_proc,proc_owner,dtrace_user
    test::::type=normal;roles=audit_role
    On Node2_
    I have logged in to Node2 as a user called *“user1”*.
    Now audit_id on Node2 would be “*user1”*.
    After this I have logged in to user “*test”* on same node(Node2) using the command “*su*”.
         Now If login to the Node1 as role “*audit_role*” what would be the audit_id on the Node1.
         #*Ssh –l audit_role Node1*
         After successful login on Node1 as “audit_role”, if some action were carried out with this login what would be the audit_id on Node1 for these actions? Whether it would be “user1” or “test”?
    please do reply if post is not clear.
    thanks,
    Rajeshwar

    Regarding your function hanging, that seems to be because your loop never ends. Also the inner query is missing a WHERE clause:
    Select Translate(comnt_rec.comment_text,'%#$^',' ') into repvalue from test_comnt;  <-- How many rows will this bring back?However I don't think you meant to query the test_comnt table at all - it looks as though you just wanted to assign the result of the TRANSLATE expression (btw please, TRANSLATE() or translate() but not Translate() - the parser doesn't care but it drives me nuts), in which case just
    repvalue := translate(comnt_rec.comment_text,'%#$^',' ');or even include the expression in the cursor itself and save yourself the trouble.
    Another thing that drives me nuts, although not the rest of the world apparently, is the name "c1" for a cursor. Why don't you name your variables "v1", "v2" etc? If you had two cursors would you seriously name the second one "c2"?
    While I'm at it, what kind of a name is "test_comnt"?

  • What would be the exact query to get above outout?

    Hi
    i hav table like:
    name phys chem math
    ram 80 73 71
    sham 75 73 85
    jadu 72 82 73
    got?
    answer would be like:
    ram phys 80
    sham math 85
    jadu chem 82
    what would be the exact query to get above outout?

    Table: HighestMarks
    Stname          Phy     math     Chem
    Aseet          50     64     90
    Rabi          80     96     34
    Pravat          57     95     90
    Sankar          80     60     45
    Query:
    select t1.stname, decode(t2.m_p,t1.phy,'phys',decode(t2.m_c,t1.chem,'chem','math')) subject
    ,decode(t2.m_p,t1.phy,phy,decode(t2.m_c,t1.chem,chem,math)) marks
    from HighestMARKS t1,
    select max(phy) m_p, max(chem) m_c, max(math) m_m from HighestMARKS t1
    ) t2
    where t1.phy=t2.m_p
    or t1.math = t2.m_m
    or t1.chem = t2.m_c
    Error:
    1.     if a single person secure highest marks in two subjects(Pravat secure highest mark in Math and Chem) then this query shows 2 subjects .It does not show the highest mark in Math
    Stname Subjects Marks
    Aseet     chem     90
    Rabi     phys     80
    Pravat     chem     90
    Sankar     phys     80
    But if 2 person secures same highest mark then this query returns results.

  • I have a desktop Mac OS X Leopard. I want to upgrade to Quicken 2007, Install Snow Leopard and download iLife '11. I heard that Quicken and Snow Leopard can clash and have problems.  What would be the best order for installing these products. Thank You.

    I have a desktop MAC OSX Leopard. I want to upgrade to Quicken 2007, install Snow Leopard, download iLife'11.  I heard that Quicken and Snow Leopard can clash..........that is why I am upgrading Quicken. What would be the best order of installing these products.  I have gotten defferent opinions and I want to be sure I install them correctly.
    Thank You.

    First, install OS X, then install your third-party software.
    How to Install OS X Updates Successfully
    A. Repair the Hard Drive and Permissions:
    Boot from your current OS X Installer disc. After the installer loads select your language and click on the Continue button. Then select Disk Utility from the Utilities menu. After DU loads select your hard drive entry (mfgr.'s ID and drive size) from the the left side list.  In the DU status area you will see an entry for the S.M.A.R.T. status of the hard drive.  If it does not say "Verified" then the hard drive is failing or failed. (SMART status is not reported on external Firewire or USB drives.) If the drive is "Verified" then select your OS X volume from the list on the left (sub-entry below the drive entry,) click on the First Aid tab, then click on the Repair Disk button. If DU reports any errors that have been fixed, then re-run Repair Disk until no errors are reported. If no errors are reported click on the Repair Permissions button. Wait until the operation completes, then quit DU and return to the installer. Now restart normally.
    If DU reports errors it cannot fix, then you will need Disk Warrior (4.0 for Tiger) and/or TechTool Pro (4.5.2 for Tiger) to repair the drive. If you don't have either of them or if neither of them can fix the drive, then you will need to reformat the drive and reinstall OS X.
    B. Make a Bootable Backup Using Restore Option of Disk Utility:
      1. Open Disk Utility from the Utilities folder.
      2. Select the destination volume from the left side list.
      3. Click on the Restore tab in the DU main window.
      4. Check the box labeled Erase destination.
      5. Select the destination volume from the left side list and drag it to the
          Destination entry field.
      6. Select the source volume from the left side list and drag it to the
          Source entry field.
      7. Double-check you got it right, then click on the Restore button.
    Destination means the external backup drive. Source means the internal
    startup drive.
    C. Important: Please read before installing:
      1. If you have a FireWire hard drive connected, disconnect it before installing the
          update unless you will boot from this drive and install the update on it.
          Reconnect it and turn it back on after installation is complete and you've
          restarted.
      2. You may experience unexpected results if you have installed third-party system
           software modifications, or if you have modified the operating system through
           other means. (This does not apply to normal application software installation.)
      3. The installation process should not be interrupted. If a power outage or other
          interruption occurs during  installation, use the standalone installer (see below)
          from Apple Downloads to update.  While the installation  is in progress do not use
          the computer.
    D. To upgrade:
    Purchase the Snow Leopard Retail DVD.
    Boot From The OS X Installer Disc:
          1. Insert OS X Installer Disc into the optical drive.
          2. Restart the computer.
          3. Immediately after the chime press and hold down the "C" key.
          4. Release the key when the spinning gear below the dark gray Apple
              logo appears.
          5. Wait for installer to finish loading.
          6. Follow instructions.
    After installing Snow Leopard you should update it by downloading and installing Mac OS X 10.6.8 Update Combo v1.1.

  • I want to delete my icloud-account from my iphone 5 and then register again, because I want to change my email-address/account name. What would be the steps to follow? How do I make sure I do not lose any information stored on/in my iphone 5?

    I want to delete my icloud-account from my iphone 5 and then register again, because I want to change my email-address/account name. What would be the steps to follow? How do I make sure I do not lose any information stored on/in my iphone 5?

    You would have to delete the existing iCloud account and create a wholly new one - you cannot change the @icloud.com email address of the one you already have.  To make a new one, you will also need an new AppleID as any AppleID can only have one iCloud account associated with it.
    Deleting the account will not delete anything off your device (if prompted for things like contacts, choose to keep them).  You will have to sync everything anew with the new account as you cannot move your sync'd content, your old backups or anything else from one iCloud account to another.  You will have to set up sync again and let it sync to the new account, and then make new backups to the new account as well.

  • Had a windows computer with my element 7.  Now just bought a Mac OSX   version 10.9.2 what would be the best photoshop elements for this machine.  I did download elements 12 from Apple store but kept getting incompatible message when trying to open a phot

    I thought elements were simple but maybe it is just me.  Having problems moving photos from iphoto to elements

    Duplicate post; see:
    had a windows computer with my element 7.  Now just bought a Mac OSX   version 10.9.2 what would be the best photoshop elements for this machine.  I did download elements 12 from Apple store but kept getting incompatible message when trying to open a phot

  • Apple loop index is empty folder!!! Can not find loop in logic browser because they just no longer exist on my hard drive, what would be the new appropriate step to take?

    Apple loop index folder is empty from the hard drive, which may explain why i can not find loop in my logic pro browser, just sort of grey in disaabled format. what would be the next appropriate steps to take??? I do have an external back up disk.

    The IDE interface that the iBook and your desktop use are the same, just a different plug size. So with the rite adapter you could put the iBooks drive in your desktop, you could even boot off it too.
    If you want to install the laptops HD in your desktop this will do it for you. Or you can use the iBooks HD as an external hard drive with this

  • Looking to upgrade my OS from 10.5.8 to something newer, what would be the best option?

    I would like to upgrade my operating system, but not sure what would be the best option. I have had the computer for several years and haven't had a problem, I just think it's time to upgrade. Any suggestions?

    Which model iMac do you have?
    The best option would be the one (OS) that meets your needs of what you want to do AND if you meet ALL the OS system requirements.  Suggest that you read the system requirements of the OS you are interested in to make sure you meet all the requirements both hardware & software.

  • I have a 15' Macbook Pro, mid 2010 running Mavericks. I want to upgrade the hardware by increasing the RAM to 8GB and replacing the HD for a SDD one. What would be the best way to install mavericks on the new HD? I have the original OS X CD.

    I have a 15' Macbook Pro, mid 2010 running Mavericks. I want to upgrade the hardware by increasing the RAM to 8GB and replacing the HD for a SDD one. What would be the best way to install mavericks on the new HD? I have the original OS X CD.
    From what I read, I have 2 choices: 1. to install OSX and then upgrade to Mavericks, but I'm not sure if this would be possible (to upgrade directly from OSX to Mavericks); and 2. to use a software called Super Duper.
    I wouldn't like to have to use a third party software to do this, so the question is: is there a better way to install directly the Mavericks not having to use a third party software?

    Install the new drive in the computer.
    Install the old drive in an external USB or Firewire enclosure.
    Boot the computer from the Recovery HD on the external drive.
    Use Disk Utility to partition and format the new internal drive.
    Clone your external drive to the internal drive.
    How to replace or upgrade a drive in a laptop
    Step One: Repair the Hard Drive and Permissions
    Boot from your OS X Installer disc. After the installer loads select your language and click on the Continue button. When the menu bar appears select Disk Utility from the Installer menu (Utilities menu for Tiger, Leopard or Snow Leopard.) After DU loads select your hard drive entry (mfgr.'s ID and drive size) from the the left side list.  In the DU status area you will see an entry for the S.M.A.R.T. status of the hard drive.  If it does not say "Verified" then the hard drive is failing or failed. (SMART status is not reported on external Firewire or USB drives.) If the drive is "Verified" then select your OS X volume from the list on the left (sub-entry below the drive entry,) click on the First Aid tab, then click on the Repair Disk button. If DU reports any errors that have been fixed, then re-run Repair Disk until no errors are reported. If no errors are reported click on the Repair Permissions button. Wait until the operation completes, then quit DU and return to the installer.
    If DU reports errors it cannot fix, then you will need Disk Warrior and/or Tech Tool Pro to repair the drive. If you don't have either of them or if neither of them can fix the drive, then you will need to reformat the drive and reinstall OS X.
    Step Two: Remove the old drive and install the new drive.  Place the old drive in an external USB enclosure.  You can buy one at OWC who is also a good vendor for drives.
    Step Three: Boot from the Recovery HD on the external drive.  Restart the computer and after the chime press and hold down the OPTION key until the boot manager appears.  Select the icon for the Recovery HD then click on the downward pointing arrow button.
    Step Four: New Hard Drive Preparation
      1. Open Disk Utility from the main menu and click on the Continue button.
      2. After DU loads select your new hard drive (this is the entry with the
          mfgr.'s ID and size) from the left side list. Note the SMART status of
          the drive in DU's status area.  If it does not say "Verified" then the drive
          is failing or has failed and will need replacing.  Otherwise, click on the
          Partition tab in the DU main window.
      3. Under the Volume Scheme heading set the number of partitions from
          the drop down menu to one. Set the format type to Mac OS Extended
          (Journaled.) Click on the Options button, set the partition scheme to
          GUID  then click on the OK button. Click on the Partition button and
          wait until the process has completed.
      4. Select the volume you just created (this is the sub-entry under the
          drive entry) from the left side list. Click on the Erase tab in the DU main
          window.
      5. Set the format type to Mac OS Extended (Journaled.) Click on the
          Options button, check the button for Zero Data and click on OK to
          return to the Erase window.
      6. Click on the Erase button. The format process can take up to several
          hours depending upon the drive size.
    Step Five: Clone the old drive to the new drive
      1. Using Disk Utility still opened.
      2. Select the destination volume from the left side list.
      3. Click on the Restore tab in the DU main window.
      4. Check the box labeled Erase destination.
      5. Select the destination volume from the left side list and drag it to the
          Destination entry field.
      6. Select the source volume from the left side list and drag it to the
          Source entry field.
      7. Double-check you got it right, then click on the Restore button.
    Destination means the new internal drive. Source means the old external drive.
    Step Six: Open the Startup Disk preferences and select the new internal volume.  Click on the Restart button.  You should boot from the new drive.  Eject the external drive and disconnect it from the computer.

  • Does Adobe Reader for iOS have the ability to open inbedded links to additional PDF docs?  If not, then what would be the best way to use these already created PDF's?

    Does Adobe Reader for iOS have the ability to open inbedded links created with Acrobat Standard to additional PDF docs?  If not, then what would be the best way to use these already created PDF's on an I Pad?

    driddy61,
    As of June 2014, none of the Adobe Reader mobile products support the hyperlink action for opening a separate PDF document.
    Adobe Reader for iOS
    Adobe Reader for Android
    Adobe Reader Touch for Windows 8
    In addition, the Reader mobile products do not open multiple windows/documents simultaneously, which would make the navigation between PDF documents nearly impossible. (Once a hyperlink takes you to a different PDF document, you have no way to go back to the original PDF document.)
    The only Adobe Reader product that fulfills your department's requirements is Adobe Reader XI (mostly for Windows/Mac desktop/laptop computers).  Acrobat Pro and Standard are paid products.
    Because you are in search of a less expensive device for your department, you could get a Windows tablet instead of a Windows desktop/laptop computer. Microsoft Surface Pro (that you've mentioned in your previous reply) is just one example.  You can also find other less expensive Windows tablets.
    Tablets
    However, please keep in mind that there are two different types of Windows tablets running two different operating systems.
    (a) A Windows tablet with an Intel-based processor running Windows 8.1 Pro
    Example: Surface Pro 3
    You can install and run traditional desktop apps (e.g. Adobe Reader XI) and new Windows Store apps ("Modern" or "Metro-style" apps).
    (b) A Windows tablet with an ARM-based processor running Windows RT 8.1
    Example: Surface 2
    You can only install and run Windows Store apps (e.g. Adobe Reader Touch) but not traditional desktop apps like Adobe Reader XI.
    In general, type (b) tablets are more affordable than type (a) tablets.  However, if you want to run Adobe Reader XI, you do need to check the technical specification of each tablet and make sure the following conditions are met.
    Processor: Intel
    Operating system:  Windows 8/8.1 or Windows 8/8.1 Pro, not RT
    Hope this helps you choose the right device for your department.  Please let us know if you have any questions about system requirements or supported features in the Adobe Reader products.

  • With SO MUCH photo editing software available, what would be the best for me if I am a digital camera newby? I do not need Photoshop CC! I do not want to spend $700 bucks! My camera is a Nikon D90. Please help.

    With SO MUCH photo editing software available, what would be the best for me if I am a digital camera newby? I do not need Photoshop CC! I do not want to spend $700 bucks! My camera is a Nikon D90. Please help.

    Where did you come up with the $700 figure?
    Photography plan - $9.99/month or $119/year - Creative Cloud Photography plan : Adobe Creative Cloud
    Single App - $19.99/month
    Complete plan - $49.99/month or $599/yr - Creative Cloud free trial & plans : Adobe Creative Cloud
    Ah - If you wish to cancel early yeah $74.99 which would total for the year at $899.88. But that final total would be if you canceled in the 12th month but if you plan on keeping it that long might as well go for the annual contract. Then cancel at the end of the term limit if you need to.
    If you are not sure what to get, Either Elements as was suggested by Peru Bob or the photography plan.

  • How do I get an SVG file to the same color profile as my illustrator file (U.S. Web Coated (SWOP) v2 and what would be the correct color profile for printing on a shirt?

    How do I get an SVG file to the same color profile as my illustrator file (U.S. Web Coated (SWOP) v2 and what would be the correct color profile for printing on a shirt?
    Thank you.

    dadanas wrote:
    Hi Simcah, I have a similar problem. Have you found out any solution?
    thanks, dan
    You need to ask the printing service provider. Dealing with color totally depends on the printing process involved and of course the machines used.

  • What would be the reason for sql server agent [MSSQLSERVER] service terminated unexpectedly?

    What would be the reason for sql server agent [MSSQLSERVER] service terminated unexpectedly?
    only below details found in error log
    07:26:44.170 spid60      
    FILESTREAM: effective level = 3, configured level = 3, file system access share name = 'MSSQLSERVER'.
    07:26:45.720 spid51      
    Configuration option 'Agent XPs' changed from 0 to 1. Run the RECONFIGURE statement to install.
    07:26:45.730 spid51      
    FILESTREAM: effective level = 3, configured level = 3, file system access share name = 'MSSQLSERVER'.
    07:28:57.840 spid64      
    Configuration option 'Agent XPs' changed from 1 to 0. Run the RECONFIGURE statement to install.
    07:28:57.840 spid64      
    FILESTREAM: effective level = 3, configured level = 3, file system access share name = 'MSSQLSERVER'.
    and below error on agent log
    2014-01-01 07:26:28 - ? [131] SQLSERVERAGENT service stopping due to a stop request from a user, process, or the OS...
    2014-01-01 07:26:43 - + [188] Scheduler engine timed out (after 15 seconds) waiting for 1 jobs(s) to stop
    2014-01-01 07:26:44 - + [098] SQLServerAgent terminated (forcefully)
    Rahul

    What would be the reason for sql server agent [MSSQLSERVER] service terminated unexpectedly?
    only below details found in error log
    07:26:44.170 spid60      
    FILESTREAM: effective level = 3, configured level = 3, file system access share name = 'MSSQLSERVER'.
    07:26:45.720 spid51      
    Configuration option 'Agent XPs' changed from 0 to 1. Run the RECONFIGURE statement to install.
    07:26:45.730 spid51      
    FILESTREAM: effective level = 3, configured level = 3, file system access share name = 'MSSQLSERVER'.
    07:28:57.840 spid64      
    Configuration option 'Agent XPs' changed from 1 to 0. Run the RECONFIGURE statement to install.
    07:28:57.840 spid64      
    FILESTREAM: effective level = 3, configured level = 3, file system access share name = 'MSSQLSERVER'.
    and below error on agent log
    2014-01-01 07:26:28 - ? [131] SQLSERVERAGENT service stopping due to a stop request from a user, process, or the OS...
    2014-01-01 07:26:43 - + [188] Scheduler engine timed out (after 15 seconds) waiting for 1 jobs(s) to stop
    2014-01-01 07:26:44 - + [098] SQLServerAgent terminated (forcefully)
    Rahul
    Can you post the output of below query
    select @@version.
    If you are using SQl server express edition ,SQL server agent feature is not available.It seems from errorlog that you can start it but actually you cannot.But first confirm what is version and edition of your SQL server
    Please mark this reply as the answer or vote as helpful, as appropriate, to make it useful for other readers

Maybe you are looking for

  • Laptop Lenovo G505S: Problem with sound in Webcam in Chat

    Hello, I have this problem: when I want to chat with someone in Gmail's Hangouts, there is a terrible sound which make normal talking very irritating and alsmost not possible. It's a sharpe, crispe sound  when I speak .I use Default settings from the

  • Backing up documents without Time Machine

    Could someone please explain to me how to back up my pictures without using Time Machine? I bought an external hard drive but when I plug it in, it immediately connects to Time Machine every time. I don't want my entire computer backed up, just pictu

  • Star Query Full Table Scan

    Hi, Folks: I have a complex SQL statement that runs very slowly. Following is the statement: SELECT T3.POSITION_ID, T12.PR_POSTN_ID, T12.PR_TERR_ID, T12.PR_REP_MANL_FLG, T9.CREATED, T10.PR_EMP_ID, T9.MODIFICATION_NUM, T12.DEDUP_TOKEN, T12.LOCATION_LE

  • Media Manager is faded out

    I just installed the new 4.6 desktop software w/ Media Manager, but when i hook my phone up to my computer, open up desktop manager, and click on the Media Manager icon, the (left) "Media Manager" side is faded out and i cant click on the START butto

  • ALE/IDOC Query

    Kind suggestion reqd. for How to see the material in the target system/client sent through ALE/ IDOC from 800 to 810. Done all the Configuration and sent a material  (MATMAS-msg Type) from 800 to 810,  1Master IDOC has been created and 1Communication