What will be the output and why

Hi All,
Can anyone help me in this.
package javatests.test;
import java.util.HashMap;
import java.util.Map;
public class CopyOfHashFunction1 {
     private int hashCode;
     public static void main(String[] args) {
            Map hashTable = new HashMap();
            String key1 = new String("a");
            String key2 = new String("a");
            System.out.println(key1.hashCode());
            System.out.println(key2.hashCode());
            System.out.println(key1 == key2);
            hashTable.put(key1, 1);
            hashTable.put(key2, 2);
            System.out.println("Size = " + hashTable.size());
            System.out.println("Value when key1 is searched:"+hashTable.get(key1));
            System.out.println("Value when key2 is searched:"+hashTable.get(key2));
}Output:
97
97
false
Size = 1
Value when key1 is searched:2
Value when key2 is searched:2I feel there should be two entries in the HashTable, because when putting the second entry in the HashTable hash collision will happen and equals() method of String will be called. As the equals() method is returning false because the object references are different so HashTable should make another entry in the same bucket.
Please let me know the answer.
Thanks
Jitendra

Yes you are right jverd because the code in String.java is like, so it used to compare the string character by character.
854       public boolean equals(Object object) {
  855           if (object == this) {
  856               return true;
  857           }
  858           if (object instanceof String) {
  859               String s = (String) object;
  860               int hash = hashCode;  // Single read on hashCodes as they may change
  861               int shash = s.hashCode;
  862               if (count != s.count || (hash != shash && hash != 0 && shash != 0)) {
  863                   return false;
  864               }
  865               for (int i = 0; i < count; ++i) {
  866                   if (value[offset + i] != s.value[s.offset + i]) {
  867                       return false;
  868                   }
  869               }
  870               return true;
  871           }
  872           return false;
  873       }

Similar Messages

  • IF WE DOES NOT SELECT ANY VALUE IN SELECTION SCREEN WHAT WILL BE THE OUTPUT

    hi
    plz give me the answer for this

    Hi bhuthapalli,
    1. Normally, all reports are designed so that
      if we do not enter any thing on screen, it will show all records.
    2. Normally reports use SELECT OPTION  and use IN for the query.
       This would take care if nothing is entered in select option.
      Nothing entered in select option means all records.
    3. If there is a parameter on the screen,
       it is usually made obligatory.
       Bcos if we do not enter anything in parameter,
        it may not give records.
       (Bcos for parameter = is used in query)
    regards,
    amit m.

  • What will be the output of this simple programm ?

    Class ABC
    public static void main(String args[])
    long i = 22222222222222222;
    System.out.println(i);
    Pls give me how to get rid of this problem.
    (Casting to long also doesnot make any effect.)
    I think range of long is very big..although i donot know exactly but bigger than what i wrote.
    so why this problem occurs that "value out of range."
    waiting...
    J stands for Java ONLY

    Change Class to class, then do this:
    long i = 22222222222222222L;

  • One line code !!!! just tell the output and why it is so ??

    #include<stdio.h>
    int main()
         printf("%d") ;
    OR
    #include<stdio.h>
    int main()
         printf("%f") ;
    }

    You codedoes not have defined behavior.
    When you pass "%d" to print,f you must also pass a second argument of type int.
    When you pass "%f" to print,f you must also pass a second argument of type double.
    If you don't pass required arguments, you cannot predict the results of the program.

  • If you have two public class in a java file what will be the error ?

    Q:If you have two public class in a java file what will be the error and how will you remove that.?

    Kannan_S wrote:
    I dont want you to be on that list . Here goes my explanation..
    A class is well defined with members and functions
    An abstract class is not defined well as compared to a full fledged class (talking more generically)
    An interface is more abstract.
    I was asking the author who has posted this question to be like a class(very clear)
    and not either as an abstract class or an interface
    Hope i have made it clear..Not in the slightest. This has absolutely no bearing whatsoever on the question asked. Not to mention that classes are classes, and all equal in the eyes of the compiler, be they abstract, concrete or interfaces. It's difficult to see what your point is, to be honest, but I suspect it wouldn't be worth seeing anyway

  • I need to change my rescue email,but i forgot the password to that email,what will i do?and i have 25 ueros on this apple account so i dont want to make a new one!

    i need to change my rescue email,but i forgot the password to that email,what will i do?and i have 25 ueros on this apple account so i dont want to make a new one!

    Have you forgotten your password? - if so, you have a problem if the email address has gone dead.
    If you know your password, go to the iTunes Store, click on Account. log in and you can change the associated email address.
    If you don't know your password, and have no email address, you are going to have problems because it's difficult to see how Apple are going to identify you as the authorised owner of the account. Contact iTunes Support: go to http://www.apple.com/support/itunes/ - click on 'Other iTunes Store Features' in the list and then on 'Podcasts'. You will see a link to either 'Express Lane', which will guide you eventually to some contact options, or you may see a link to email them.

  • I'm going to save my old Hi8 tapes on a hard disk using final cut pro x, to save it for the future. But how shall I export it, and in what will be the best quality to save it in?

    I'm going to save my old Hi8 tapes on a hard disk using final cut pro x, to save it for the future. But how shall I export it, and in what will be the best quality to save it in?

    Hi Carsten...good luck with your project.. I had just about as many Video8 & Hi8 tapes as
    you that I digitized and eventually brought into FCPX..took me many months not weeks
    to do so,BTW, as each tape was 60-90 minutes in lenght...and many hundreds of
    gigab ytes of storage ( uncompressed AVI files)..it's tedious work unless you plan to farm
    it out to a processing house...also regarding eventual storage format...remember
    Hi8 is 400 lines or about 540X480 in todays resoultion metrics..you can't make hi-def out
    of source that starts out as 400 lines...in my case I rewrapped the avi files into .mov
    containers and imported the mov files into FCPX where I got rid of the hundreds of
    minutes of Colorado mountain landscapes to get to that one minute shot of the kids
    on horseback  ( late 80's for most of my archives)..so its a job..scouring thru 30X90 min
    of source to not miss those precious memories takes diligence and hard work but its worth
    it; eventually I encode the uncompressed video I want to save in H.264 format Staandard
    Def not HiDef

  • I accepted a version update and now iTunes closes on launch with the message "iTunes has stopped working. Windows will close the program and notify you if a solution is available." What to do?

    I accepted a version update and now iTunes closes on launch with the message "iTunes has stopped working. Windows will close the program and notify you if a solution is available." What to do?

    Hey Todd Rubenson,
    Thanks for the question. I understand that you are experiencing issues with iTunes for Windows unexpectedly quitting. The following resource may provide a solution:
    iTunes for Windows Vista, Windows 7, or Windows 8: Fix unexpected quits or launch issues
    http://support.apple.com/kb/TS1717
    Thanks,
    Matt M.

  • What will be the peoplesoft query to calculate voluntary termination count and involuntary termination count? I am working on OBIA HR analytics workforce deployment reports and need to validate the reports

    what will be the peoplesoft query to calculate voluntary termination count and involuntary termination count? I am working on OBIA HR analytics workforce deployment reports and need to validate the reports. I also want to know the tables involved

    Hi Andrew,
    Part A:
    I've done some restating of the question, and distributed the calculations among several fields, not all of which need to be included on the visible layout. Other than formatting the Date fields and moving the 'Completed Date' field and its label, I've left this in the default "Layout 1" produced by AppleWorks.
    Field List:
    Priority: Popup menu with six items: 00, J, D, 1, 2, 3  Defaults to 00
    TL (time limit in months): Calculation:  CHOOSE('Priority',0,1,3,4,6,12)
    Received: Date. Option: Automatically insert today's date (ie. Date Record created) (may be edited)
    Target Date: Calculation:
    DATE(YEAR('Received')+INT(MONTH('Received')+'TL')/12,MOD(MONTH('Received')+'TL', 12),DAY('Received'))
    Remaining (Days): Calculation: INT('Target Date'+1-NOW())  (see revision below)
    Completed: Checkbox. Set default value to Unchecked.
    Completed Date: Date: Entered manually
    OnTarget: Calculation: IF('Completed',IF('Completed Date'<'Target Date',"On Target","Over"),IF(INT(NOW())>'Target Date',"Over","On Target"))
    The On Target field shows the current status of the case while still open, and the state on the closing date when it was closed.
    Having done that, I was unhappy with the Remaining field continuing to calculate an ever larger negative number after the case had been closed. Hence this revision below:
    Remaining: Calculation: IF('Completed','Target Date'-'Completed Date',INT('Target Date'+1-NOW()))
    Shows the number of days remaining while the case is open, the days remaining at completion if the case has been marked Completed and the completion date entered.
    Rsults (and some further formatting of the Layout) below.
    Part B:
    You will need Subsummary parts when sorted on Completed and on On Target. Fields can appear on  a Layout only once, so each subsummary part will need a separate Summary type field for each field to be summarized.
    Regards,
    Barry

  • HT5624 my child created a passcode for my i phone and he forgot that what will be the reset procedure

    my child created a passcode for my i phone and he forgot that what will be the reset procedure

    Locked Out, Forgot Lock or Restrictions Passcode, or Need to Restore Your Device: Several Alternative Solutions
    1. iOS- Forgotten passcode or device disabled after entering wrong passcode
    2. iPhone, iPad, iPod touch: Wrong passcode results in red disabled screen
    3. Restoring iPod touch after forgotten passcode
    4. What to Do If You've Forgotten Your iPhone's Passcode
    5. iOS- Understanding passcodes
    6. iTunes 10 for Mac- Update and restore software on iPod, iPhone, or iPad
    Forgotten Restrictions Passcode Help
                iPad,iPod,iPod Touch Recovery Mode
    You will need to restore your device as New to remove a Restrictions passcode. Go through the normal process to restore your device, but when you see the options to restore as New or from a backup, be sure to choose New.
    You can restore from a backup if you have one from BEFORE you set the restrictions passcode.
    Also, see iTunes- Restoring iOS software.

  • I can't open Itunes on my laptop. "Itunes has stopped working. A problem causes the program to stop working correctly. windows will close the program and notify you if a solution is available" is the message. what is the problem here?

    I can't open my Itunes program in my laptop computer with windows 8. the message is "Itunes has stopped working. A problem causess the program to stop working properly. windows will close the program and notify you if a solution is available". I reboot  the machine, Uninstall and re install the  Itune program, stilll the same message pops up.

    The first thing to try is System Restore to take you back to a point in time when it did work. If that is not successful, create a new user on the computer. log in with that and see if ID will start. This will tell us if the problem is in the system/program or the user account.
    If it works in a new user account, see Replace Your Preferences and in addition to replacing the prefs, empty the InDesign Recovery folder that will be in the same location and the InDesign SavedData file.

  • What happens to the outputs when I reconfigure the 6524 card?

    I have an application where I want to recongure the card throughout my program. For example I might initially want to set a single 8 bit port, so I could use Dig_Prt_Config and Dig_Out_Prt. Then I might want to output a batch of data using buffered IO so I use DIG_Block_PG_Config and DIG_Grp_Config to configure the card again. My question is what happens to the output states when I do this. If the port is then assigned to a group what happens to the outputs at that point? Do they remain unchanged until I do a Dig_Block_Out or do they all turn off? I guess I will find out when I try it, but it would save me from throwing away code if I knew now,
    Thanks,
    David

    David,
    I assume you have the 6534 board. On the 6534 board, reconfiguring the port will not affect the output value. Well, as long as the direction map doesn't change. Anyway, hope that helps.
    Ron

  • Where's the music on iTunes, and what's with the quality and compatibility?

    I'm just curious as to whether anyone else has had this issue or not: Does anyone else feel like, after searching for specific songs, there's just little to nothing in the database? I feel like most of my searches are pointless because iTunes has either no data of my requested search and/or only has bits and pieces of it.
    Another question I have: After having a slightly successful search, why am I left with low quality tunes? I mean, you can hear the compression... badly. (I know it's not my speakers)
    Last question: If I'm paying for the song, shouldn't I be allowed to download a universal file? iTunes uses a unique format that no other application uses. In other words, more money has to be spend for m4a to mp3 converters (unless you're a cracker [not a racial comment]).
    To me, I value iTunes and its team, so I'm sorry if I've offended anyone. I understand there are contracts involved with the artists and it's hard to please ALL of the subscribers. But seriously, where's the music on iTunes, and what's with the quality and compatibility?
    Custom   Windows XP Pro   Negative, I am a meat popsicle.

    Today I thought of finally putting lyrics on my songs. So I've been quite some time busy doing that, then I tried it on my iPad (2) and I can't find them. Just as the people above say. Then I went to search where I can find them and I found this page. I'm really dissapointed and I don't understand how something like this could happen. So I hope Apple will fix this soon.
    (I'm just posting this so that Apple will do something about it)

  • If BW system is down for several hours, what will be the status of the Jobs

    Hello Gurus,
       I don't know where i should post this issues! anyways .....! i need some information. One of our BW production system will be down for about 12 hours tomarrow to move it on to new hardware and this current system has lots of scheduled jobs with run daily and hourly..! so my question is ..what will be the status of this jobs which fall in between this down time?
         as per our basis team information....they said that all these jobs will be queued up and when once the system is online ...these jobs will access all the avalable processess and if this thing happen....! then the system will have a VERY BAD performance and user cannot use this BW system...they cannot even open the bex analyzer.
          so...i thought of deleting these queued jobs. can any one tell me WILL THESE JOBS WILL BE SCHEDULED FOR NEXT DAY??? OR IS THERE ANY OTHER WHY TO CONTROL THIS SITUATION?? our process chains are locked for modification..so, we cannot even re-schedule them in prod system.....
             aaaaaah! can any one HELPP MEEEEE@
    I will award full points for your suggestion

    Hi,
    when you'll restart you SAP system all jobs will be displayed with a delay since they didn't run during your downtime.
    And that's true that they will be queued and fired as soon as a system resource will be available. That means a lot of paralel processes with system overload and usually subsequent errors in loading data.
    As per suggested already, the best would be to shift the scheduling.
    Another option is to execute the report BTCTRNS1 before shutting the system down. This will change all background job status to a "suspended" mode.
    when your system is up again you will be able to release (or reschedule or cancel or any other action) single jobs in a controlled manner.
    When you've finished with this task then don't forget to run BTCTRNS2 in order to enable background jobs to be executed.
    hope that helps...
    Olivier.

  • What is your favorite transaction and why?

    Just wondering what your secret tools are... Willing to share? Transactions you use all the time, and without them you would be, uh, toast...
    My favorite one is SE84 Repository Information System. I use it regularly to find objects in repository, like database tables, views, table fields, function groups, function modules, programs, logical databases, message classes, message number, SET/GET parameters, transactions, variants, screens, business add-ins, customer exits, change requests and authorizations.
    A useful hint: You can also search by application hierarcy. For example, in 4.6c to find customer exits within MM, do as follows:
    1. Start SE81
    2. Select subtree MM with F9
    3. Click Information system. SE84 is displayed.
    4. Click Envir. and then Exit techniques and then Customer exits. Click enhancements. A search screen is displayed and development class field is pre-filled.
    5. Press F8
    What is your favorite transaction and why?
    Regards,
    Jarmo Tuominen

    clearly SE80.
    Starting 4.7 you have a button on top of the tree navigation where you can click the information system.
    So you have (at least) three transactions in one: SE80, se84(85 and SE38.
    I wonder why still some people prefer SE38. It's just SE80 minus functionality and overview plus wasted screen space.
    Is there any existing function you can execute from SE38 that is not available in SE38? A lot the other way round.
    regards,
    Clemens

Maybe you are looking for

  • Memory leak in xerces on Solaris platform

    We are seeing memory leaks with xerces 2.5.0 on the Solaris platform. Has anyone encountered a similar problem and is there a fix for it.

  • Purchase order for external service

    Dear experts, I tried creating a purchase order for a service, with account assignment unknown U, with item category D, but after entering the item details in the item overview, it keep saying " ACCOUNT ASSIGNMENT UNKNOWN NOT ALLOWED WITHOUT GOOD REC

  • Changed RAM in Macbook Pro now the Apple logo appears then switches off

    Hi all, I hope someone can offer me some assistance with this. I'm using a Macbook Pro (unsure of the year) It's a 13" running an i5 and 4GB of ram. I believe it is running Mountain Lion. I took the back off and added one strip of 4gb to go along sid

  • Column Total in RTF

    Hello, Here is a sample of my report. Project Name | Task Name | Current | Bill | Apply P1 | T | 300 | 0 | 300 (sum of T1 and T2) | T1 | 200 | 0 | 200 | T2 | 100 | 0 | 100 P2 | T | 400 | 0 | 400 Grand Total P | T | 700 | 0 | 700 (Total P1 + Total P2)

  • PLS-00201: identifier 'GLOBALPKG.RCT1'

    Hi, Thanks for assistance. I have created scripts for procedures and functions in sql server 2000. Then I have migrated it to Oracle using Swissql tool. After migration it one sql script was generated in which entire code is compatible to oracle synt