building Hashtables from array of Strings

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • vikas1008
    New Member
    • Sep 2007
    • 2

    #1

    building Hashtables from array of Strings

    I have extracted some integers from a text file and stored them in array of String. Now I want to make hash table from those integers (stored as string). Help.
  • ibahealth
    New Member
    • Nov 2007
    • 6

    #2
    Originally posted by vikas1008
    I have extracted some integers from a text file and stored them in array of String. Now I want to make hash table from those integers (stored as string). Help.

    hi i have some suggestion ,these sugesstions are based an ur question as posted ,i don't know ur actual requirment
    1. why you had taken a string array u can take directly an integer array
    2.or can u iterate the array in loop and check every element inthe loop either it is string or integer
    (if integer)
    use Integer.parseIn t();
    and put it in the HashTable.put(" KEY" ,Value);

    ok i think this will give u an idea may not perfect solution i think because thisis based upon ur Query
    regards
    chiru

    Comment

    • ibahealth
      New Member
      • Nov 2007
      • 6

      #3
      Originally posted by ibahealth
      hi i have some suggestion ,these sugesstions are based an ur question as posted ,i don't know ur actual requirment
      1. why you had taken a string array u can take directly an integer array
      2.or can u iterate the array in loop and check every element inthe loop either it is string or integer
      (if integer)
      use Integer.parseIn t();
      and put it in the HashTable.put(" KEY" ,Value);

      ok i think this will give u an idea may not perfect solution i think because thisis based upon ur Query
      regards
      chiru
      or u can do one thing also if ur not able to put idivisusal arguments into hastable according to the hash table property the key and values are only string i think for that u can directly put string array(object) into hash table and assain that hastable object to a integer array or varable based on requirement then iterate for indivisual arguments
      as like this
      String demo_array []={6};
      hashtable demo_hash=new HashTable();
      demo_hash.put(" DemoValue",demo _array );
      int demo_array1=dem o_hash.put("Dem oValue",demo_ar ray );
      u can iterate this intewger vairable
      regards
      chiru[/QUOTE]

      Comment

      • r035198x
        MVP
        • Sep 2006
        • 13225

        #4
        Originally posted by vikas1008
        I have extracted some integers from a text file and stored them in array of String. Now I want to make hash table from those integers (stored as string). Help.
        Why did you read the values into an array first when you wanted to put them in a hashtable at the end?

        Comment

        • heat84
          New Member
          • Nov 2007
          • 118

          #5
          Remember that hashtables dont store nulls.

          Comment

          • JosAH
            Recognized Expert MVP
            • Mar 2007
            • 11453

            #6
            Originally posted by heat84
            Remember that hashtables dont store nulls.
            Ints can never be null.

            kind regards,

            Jos

            Comment

            Working...