HashTable 2 « HashTable « Java Collection Q&A

Java Collection Q&A
3.Array Byte
4.Array Char
5.Array Convert
6.Array Dimension
7.Array Integer
8.Array Object
9.Array String
14.Garbage Collection
Java Collection Q&A » HashTable » HashTable 2 

2. What is the usage of JAVA hash table?    coderanch.com

4. Hashtable IO    coderanch.com

Hi, when I click the regi button in my code the keys/values are written to a text file but the text written to the txt file is sometimes the same as the text written before (even when I start the program up again). Help please. package piced; import java.awt.BorderLayout; import java.awt.Color; import java.awt.GridLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.io.BufferedReader; import java.io.File; ...

5. HashTable Problem    coderanch.com

First of all, forget about class Hashtable. Use class HashMap instead. Hashtable is an old, legacy collection class that has been replaced by HashMap. You can choose any type you like for the keys and values of a HashMap. The type that you use for the keys has to have an appropriate implementation of the equals and hashCode methods. Here is ...

6. Normalise hash table.    coderanch.com

8. using hashtable as return type    coderanch.com

I think what the other poster might have meant was that "TreeMap" is a more flexible datatype than HashTable, and therefore might be regarded as a better choice to return. You can write the routine to return a TreeMap and implement it today with HashTable, and it makes it easier to change your implementation later. If you do that, of course, ...

9. Hashtable search    java-forums.org

Hello, I have a Hashtable with little over 1.5 million entires. Hashtable Key is name, and Value is number of occurrences of that name. I'm trying to implement this function. Java Code: /** * Get k names with the highest weights in the set, where k is a positive integer value. * If the cardinality of the set is less ...

10. (Help) Hashtable for adjacency list    java-forums.org

hey people, i have a little problem about implementing a Hashtable in my project. i want to store nodes and the edges between them in the hashtable. Java Code: Map> adj= new HashMap>(); ... // add a connection from -> to public boolean add(City from, City to) { List tos= adj.get(from); if (tos == null) // from is not ...

11. hashtable chaining    java-forums.org

I'm having trouble with finishing the remove and rehash methods. Here is what the remove method should do: set index to key.hashCode()%table.length if index is negative, add table.length if table[index] is null key is not in the table; return null search the list at table[index] to find the key if the search is successful remove the entry with this key and ...

12. Need help with hashtable chain    java-forums.org

I need help with the remove and rehash methods. Here is my code Java Code: import java.util.*; public class HashtableChain { private LinkedList>[] table; //the hash table private int numKeys; //the number of elements within hash table private static final int INITIAL_CAPACITY = 101; // the size of the table private static final double LOAD_THRESHOLD = 3.0; //the ...

13. hashtable    java-forums.org

Hi my task is to read a csv file in the following format and display it in a jtable for which i want to store it first in a datastructure so that i can filter it depending on the columnnames csv file looks like: Anton;12;male;ABC Martha;13;femal;ZXY so i read each line and want to store in a hashtable following code is ...

14. hash table    java-forums.org

An insecure method of encrypting text is to replace a known word with another specific word. To ensure that the encryption is reversible, no two words are replaced by the same word. Your task is to decrypt several encoded lines of text, given the set of replacements. Input The input consists of a line containing an integer n followed by n ...

15. hash table chaining    java-forums.org

I am trying to make hash table with different functions for making the table, and each function contains options to handle collisions. I have each function working with linear and quadratic probing, does anyone know how to get it to work with chaining? In the code below I have the case using java's hash function, and case 1 and 2 within ...

16. Hash-tables IO    java-forums.org

public static void writeB(Integer increase) { try { PrintWriter out = new PrintWriter("/Users/eric.manget/Desktop/points.txt"); if((fileObj.containsKey("Bremner's") == false)){ Integer zero = 0; fileObj.put("Bremner's",zero.toString()); out.print(fileObj); System.out.println("lol"); System.out.println("Hashtable contains " + fileObj.size() + " key value pairs."); } else{ System.out.println(fileObj.get("Bremner's")); Integer val = Integer.parseInt(fileObj.get("Bremner's")); Integer value = val + increase; fileObj.put("Bremner's",value.toString()); out.print(fileObj); } out.close(); } catch (IOException e) { } } public void readH(){ try{ ...

17. Hashtable saving    java-forums.org

19. Using get method on hashtable    forums.oracle.com

I want to retrieve a key from activeData, check to see if that key exists in passiveData, if it does I then want to check if the values attached to the key match. Once the comparison is made I remove the key and values from both tables, and if passiveData still has items left in it then activeData was missing some ...

20. HashTable    forums.oracle.com

How do I insert into a hastable a String and an int? I need it so that I have a key in the hash, "Here is a String", with an associated number, and then I have to be able to take tghat number, add 1 to it, and put it back in the hash.

21. Editing hash table data    forums.oracle.com

Hi all, I was just wondering how you can edit data that is already stored in a hashtable? I want to create a method that lets a user of my system edit the currently stored data, but there doesn't seem to be any predefined way of going about it. Would it be done using a combination of .remove and .put methods? ...

22. HashTable    forums.oracle.com

Can someone please help me with this hashtable question: I have a 2d array of String : String[][] example{ { " 0 1 ", " 1 2", "2 1 0"}}; as input I have to split them into two arrays: 1 an array of strings which hold the first element of the i/p array (String[] a) 2 An array of Integers ...

23. Enumeration over Hashtable    forums.oracle.com

24. What is a Hash Table?    forums.oracle.com

in layman terms? I am taking a course online, to satisfy a prerequisite... and I found out that i paid $500 to teach myself out of a book and turn in homework. It's hard to learn something with no instructor. Now I know there are plenty of people out there who are like "oh god what kind of computer scientist does ...

25. Can somebody help me with hashtable queries    forums.oracle.com

I have build a program in Java where you enter the name of someone and their age using hashtables. It can add many names as it wants and display them onto a textarea. The program also has other functions like deleting a record and searching for a record. I am trying to create a query where i can shortlist people who ...

26. error in printing hashtable    forums.oracle.com

Hi, I would like to ask some advice about the error I have in my code. The thing I'm trying to do is to store the values of two ArrayLists into the hash table (this values are the name and the score). But when I'm trying to print the values from the hashtable I have a null pointer exception. Can't find ...

27. hashtable.....    forums.oracle.com

Hi All, i want to create a hashtable with predefined capaccity: I have a method and in that method i created a hashtable.... public static abc() { Hashtable ht=new Hashtable Hashtable(int initialCapacity, float loadFactor) { if (initialCapacity < 0) throw new IllegalArgumentException("Illegal Capacity: "+ initialCapacity); if (loadFactor <= 0 || Float.isNaN(loadFactor)) throw new IllegalArgumentException("Illegal Load: "+loadFactor); if (initialCapacity==0) initialCapacity = 1; ...

28. hashtable    forums.oracle.com

29. Passing a hashtable and retaining a copy?    forums.oracle.com

Thanks for the responses guys. I seem to have missed out on the important fact that the two Hashtables were set over IXC. So, with this, it really seems to be a copy made rather than both originalTable and newTable pointing to the same reference. That's why they didn't seem to be affecting each other.

30. HashTable    forums.oracle.com

ejp, Thanks for the prompt response. The client inputs the staff name into a field on the client side. I suppose my question is how do I get method CaseN to understand that I am asking it to get the information in the first "" if it is supplied with the information from the second "". Case E works but I'm ...

31. Hash Table Extract    forums.oracle.com

32. hash table question    forums.oracle.com

Yes, I know. But I'm doing an assignment in which it seems easiest to implemet an array as a hash table instead of using the Hashtable or HashMap classes from the java API. There are various reasons for this but I don't want to go into the details. If someone has a solution or suggestion, please share it with me. Thank ...

34. how to handel the enderd data in a hashtable?    forums.oracle.com

35. Table ADT with a Hash Table    forums.oracle.com

I'm suppoed to insert each word from a text file (a "dictionary") into a Table ADT, and implement the Table ADT with a hash table. I want to use a linked list with the Table ADT. So how would I go about this? I'm guessing I need to create the linked list (node) class, add all the words into the linked ...

36. Hashtable    forums.oracle.com

37. unordered HashTable    forums.oracle.com

You should follow Java naming conventions. Method names start with a lower-case letter. Anyway...so this is a homework assignment where you're implementing a hash table, correct? And you have apparently implemented an add method that takes a hashcode, and a String, which apparently is the value you're storing. Correct? Why are you storing the hashtable value in the array? What do ...

38. Hashtable    forums.oracle.com

39. question regarding hashtable    forums.oracle.com

jose_an wrote: ArrayList() Constructs an empty list with an initial capacity of ten. what does capacity mean here, i dont think its the number of elements.. I was able to add more than 10 elements and successfully print them out.. An ArrayList is basically an array that grows. Since arrays have a set size, a new array is constructed in practice ...

40. Hash table    forums.oracle.com

You will find that theory and other questions outside the realm of strictly Java are often discussed here, but that happens when people feel like discussing it, not just because somebody wants answers. It wouldn't be at all surprising for somebody to answer your question about the load factor here. That doesn't change the fact, however, that the earlier advice to ...

41. Hashtable limitation    forums.oracle.com

42. Using lookup in Hashtable    forums.oracle.com

43. A question that has been asked a thousand times before: Why not hashtable?    forums.oracle.com

I have been reading a lot of places, and nobody seems to be very fond of Hashtable. I know you can make a hashmap synchronized, but is that better than just using hashtable, which is already synchronized? I have been using hashtable to store and update data used by multiple threads. Can somebody show me the coolerist way to make a ...

44. Passing a hashtable between two different classes?    forums.oracle.com

So basically I have two classes and a Hashtable in one of them, and what I want to do is let the other class have access to it either by making a second copy of the table or simply just referring to the original one (better). Can anyone whip up some quick example code or point me in the right direction ...

45. Updating a hashtable    forums.oracle.com

46. Hash Table question    forums.oracle.com

47. Iterarator for hash table.    forums.oracle.com

You haven't even provided something with valid syntax - where is this "cursor" variable defined? And in one method you are using and incrementing something called "pointer", and somewhere else "cursor", so maybe you're mixing two different variables but trying to use them for the same purpose and they are out of sync.

48. Hashtable Doubt    forums.oracle.com

49. HashTable    forums.oracle.com

50. HashTable cannot be resolved to a Type    forums.oracle.com

1.) Welcome to the forum! 2.) The problem has already been solved (as you could have found out if you actually read the replies) 3.) The thread is from march. It's been dead for 6 months, noone is interested in reviving it. So please refrain from reviving old thread, especially if your post adds nothing new. Thanks.

51. Unexpected result in efficieny comparson of Hashtable and ArrarList    forums.oracle.com

} bw.close(); fw.close(); } catch (IOException e) {} } } b. Timed to create a unique valielist from the above file, uing ArrayList and Hashtable respectively. Following is my code: import java.io.*; import java.util.*; public class test2 { public static void main(String[] args){ String sLine; int iVal; long startTime, endTime; ArrayList al = new ArrayList(); Hashtable ht = new Hashtable (4999); ...

52. Something like Hashtable    forums.oracle.com

Hi, I have a country dropdown in which I set the value as a two-letter cuntry-code and the label is the country name. The countries are fetched from a ResultSet and so I need to loop this and set the values in a list. I need a list that contains two values for each index, which I can access independently. I ...

53. Adding items to hash table    forums.oracle.com

54. Question about java.util.Hashtable.    forums.oracle.com

55. Trying to develop a hash table, quadratic probing... help    forums.oracle.com

Hey all, I have an assignment over thanksgiving break to implement quadratic probing on a given hash table. From my notes, the way this thing works is that to search for the next item, I do: key % table size And if that position is taken, try (key % table size) + 1^2 (key % table size) - 1^2 (key % ...

56. HashTable pointers?    forums.oracle.com

I have a hash table of objects where each object key is it's own unique name String. Many times I will need to use the same base object for multiple items in the list (ie create copies of the object). However, a change to one of these objects will make every single one of the same object in the list have ...

57. Problem with hashtable    forums.oracle.com

58. confusion in hashtable    forums.oracle.com

59. Hashtable?    forums.oracle.com

i havent done anything towards the hashtable yet but this was the basis of my program. i still have to fix it but right now i will ask 4 a name and birthday and store them in an array. i havent wrote all the code yet. and i didnt copy paste anything

60. Simple Hashtable problem - Iteration :-)    forums.oracle.com

61. Over riding hashtable get and put method    forums.oracle.com

Why don't you use a map whose Key and Value are the actual types for which it is a map? Suppose I wanted to associate address and phone number with names. I might use a map that associates name (key)and phone number (value) and then wonder how I could coerce put() to accept the address as a third parameter. Better, I ...

62. iterating a hashtable    forums.oracle.com

63. Hashtable get inconsistence problem!    forums.oracle.com

64. Hashtable question    forums.oracle.com

65. hashtable problem    forums.oracle.com

No. What you could do, though, is write your own class that implements java.util.Map, and makes use of the Observer pattern to notify you when values changed. You can still use a Hashtable - or better yet, a HashMap - internally to do all the dirty work. Basically, all the method calls of Map just delegate down to the internal Map ...

66. Hashtable Doubt    forums.oracle.com


/// Prints the information in the Data hashtable to the console. /// Output should be sorted by key /// References should be printed between '<'>' /// The output should look like the following : /// /// /// Alpha...... -3 /// Bravo...... 2 /// Charlie.... /// Delta...... 1 /// Echo....... /// --etc--- /// /// static void PrintSortedData() ...

67. getting nulls out of hashtable with funky for loop    forums.oracle.com

1. Your monster method is way too long, doing too many different things. 2. You dump all these attributes for different rows into the map. Why don't you create FinanicalAccount objects (?) as you parse the input? Then you could store them in a list or insert them into your database as you go along.

68. hashtable resizing    forums.oracle.com

According to this article, http://en.wikipedia.org/wiki/Hash_table#Table_resizing the time complexity of a hashtable resizing is done in O(1). So is hashtable resizing considered costly only for memory complexity since you resize to more indices than you need? Why is resizing a hashtable that implements chaining better than not resizing and continuing chaining? If you don't resize, lookup will turn into an O(n) operation, ...

69. NullPointer with Hashtable    forums.oracle.com

70. Java HashTable    forums.oracle.com

71. Hashtable in core of a class    forums.oracle.com

Hi, I try to use Hashtable in the core of a public class. But I cannot access to put method from Hashtable from the core of the class. I must access put method from a method of this class. Why ? import java.util.Hashtable; public class Help { Hashtable helpHash = new Hashtable(); ... } Thanks Linux, Java 1.6, compiled ...

72. Combine two hashtable into one    forums.oracle.com

Hello, I need to combine two hashtables (including the key, value and their relation)into a new hashtable. I can go through every pari in each hashtable and put it in the new hashtable, but I think that could be very slow if I have big hashtables. Does anyone have a quick way to do it? Any suggestion will be appreciated. kiki ...

73. trying to solve the hashtable problem;    forums.oracle.com

public static void addItem(String keyid, String t, double p, int q){ // array size of 4 for my value in hashtable "b" String [] array = new String [4]; // puting all my variables into string array //including my keyid as the first in array[0] array[0]=keyid; array[1]=t; array[2]= String.valueOf(p);//casting of double type to string array[3]= String.valueOf(q);//casting of int type to string ...

74. trying to solve the hashtable problem;    forums.oracle.com

public static void addItem(String keyid, String t, double p, int q){ // array size of 4 for my value in hashtable "b" String [] array = new String [4]; // puting all my variables into string array //including my keyid as the first in array[0] array[0]=keyid; array[1]=t; array[2]= String.valueOf(p);//casting of double type to string array[3]= String.valueOf(q);//casting of int type to string ...

75. Error in Hashtable put method-Can not resolve symbol    forums.oracle.com

/** * @(#)server.java * * * @author * @version 1.00 2008/3/22 */ import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.net.ServerSocket; import java.net.Socket; import java.util.*; public class server { static int key1=0; static Hashtable nameHolder=new Hashtable(); //static ArrayList nameHolder=new ArrayList(); //static ArrayList clientsConnected =new ArrayList(); static Hashtable clientsConnected =new Hashtable(); public static void main(String[] args) throws IOException { //nameHolder.add("controlelement"); Socket ...

76. ConcurrentHashMap VS. HashTable    forums.oracle.com

77. Hashtable locking question    forums.oracle.com

I looked up the SynchronizedMap source and don't see a big difference between it and Hashtable. SM uses synchronized blocks in every function and Hashtable uses synchronized methods. Is their a difference? If it's just a matter of one way being preferred over another let me know. Also, I'd still like an answer to my original question about the locks...is the ...

78. Hash table optimisation    forums.oracle.com

I have a question about optimisation of a hash table using the initial capacity parameter. I need to store on average between 8-16 million entries (integers) in the hash. I have experimented with setting the initial capacity at 500 000, 1 000 000 and 8 000 000. 1million appears to perform the quickest, but I need to test more to see ...

79. Populating a Hashtable from a 'for' loop    forums.oracle.com

80. Hashtable    forums.oracle.com

81. Urgent: Hashtable Problem    forums.oracle.com

82. Hashtable usage    forums.oracle.com

Hi thx for ur response.. Of course I too have a knowledge of JDBC My query would be something in brief like this: once I connect to my dbase using jdbc...i need to retrieve data from the dbase.afterwhich i need to populate the same on to my various pages..... As the data retrieved is gonna be huge,IN THIS CONTEXT IS THERE ...

83. Hash table in version 1.5.0_06    forums.oracle.com

84. Quick Hashtable question    forums.oracle.com

Hello all, before hand thank you if you are able to assist. My question is that I have a two DB (SQL) strings 1 and 2. 1 has people and 2 has the account of the person. so data is like this... person account alex 20001 alex 56547 maria 879787 maria 65464 maria 789789 I want to put then in a ...

85. Hashtable    forums.oracle.com

What I would like is how should I go about sorting the hashtable in ascending order in respects to the Nric? And how is it possible for me after having the sorted method have the function perform at the btnSort button? I'm very sorry to be holding you up so late into the night Dr.

86. HashTable    forums.oracle.com

87. HashTable    forums.oracle.com

88. type of hashtable...    forums.oracle.com

89. populating a hash table    forums.oracle.com

90. Hash Table    forums.oracle.com

91. Is this possible with a hashtable?    forums.oracle.com

i.e. to clarify I have a value 10 in my hashtable I have a value 10.02 so if we do a comparison, even though the values are not the same the hashtable value falls within the comparison range and hence we'd like to return true or whatever. I've been wracking my brains and I can't seem to find a way to ...

92. HashTable Help    forums.oracle.com

We have an issue that is related due to a hash table, we have a hashtable that contains the list of id's. sql = ""; // here is an sql query, this returns data. rs = _stmt.executeQuery(sql); Hashtable = new Hashtable(); while(rs.next()) { String pId = rs.getString(1); projectsLocked.put(pId,""); Debug.write(Debug.OUTPUT, "The ID Locked is:"pId"."); } Is it possible to map many ...

93. Casting Hashtable to list    forums.oracle.com

94. Hashtable problem    forums.oracle.com

My guess is that the compiler is complaining because sometimes your code doesn't return anything. Is this correct? If so, it would happen because there's a path through the method such that an exception is thrown before the return statement is reached. Control then goes to the catch block, which doesn't return anything. Control then passes past the catch block, where ...

95. best way to sirialize Hashtable    forums.oracle.com

96. hashtable problem please help    forums.oracle.com

97. Problem using Hashtable    forums.oracle.com

Thanks a lot mait! Actually I do understand all my compilation errors and I do recognise that I shouldn't cast to double since I do know that getY() returns double. The casting to double was just an act of despair, thus I think you can understand what a man can do when he's disparate! The fact is that I hadn't use ...

98. help with Hashtable oddity    forums.oracle.com

I have written some code as part of a program to parse a data file and I'm seeing some behavior with a hashtable that I was hoping someone could help with. The key values are simple enough, Strings containing the values "0" through "10" inclusive. What I am seeing is that as I build the hashtable, the key/value pair for "0" ...

99. ConcurrentHashMap vs Hashtable    forums.oracle.com

ConcusrrentHashMap vs Hashtable As per my understanding ConcusrrentHashMap provides all the features of hashtable. On top of that it provide extra important feature that Retrieval operations (including get) generally do not block, so may overlap with update operations (including put and remove). So can anybody give a example where we hashtable can not be replace by ConcusrrentHashMap

java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.