Tuesday, 15 January 2013

java - Why can't I properly retrieve from my hashtable? -


Why do not I recover from my hashtable properly? I create a hashtable that has both key and value form in the form of coordinates (a class I have created). And then I can not retrieve the x value from my coordinate object

  translate public coordinates offsettipxx (int x, int y) {translated for pixel coordinates for translation Cell coordinate input = new coordinate (x, y); Coordinate output pixel coord; Hashtable & lt; Coordinates, coordinates & gt; Table = new hashtable & lt; Coordinates, coordinates & gt; (); For (int r = 0; r  

Coordinate class:

  Public class coordinates {Private int x, y; Public coordinates (int x, int y) {this.x = x; this. Y = y; } Public int getX () {return x}} Public int getY () {return y;}}  

LOGTABLE:

  03-17 13: 55: 53.690 1961-1961 / com.example.sam.matrix D / viewerimple: ViewOptimant InputStation ACTION_DOWN 03-17 13:55: 53.780 1961-1961 / com.example.sam.matrix I / System.out: Hit Board 03- 17 13: 55: 53.780 1961-1961 / com.example.sam.matrix I / System.out: 5 03-17 13:55: 53.780 1961-1961 / com.example.sam.matrix I / System.out: Hit Translation 03-17 13: 55: 53.780 1961-1961 / com.example.sam.matrix E / InputEventReceiver: Input Event Sending exception. 03-17 13: 55: 53.780 1961-1961 / com.example.sam.matrix E / MessageQueue-JNI: Exception in the message callback: Handle Rescue Callback 03-17 13: 55: 53.800 1961-1961 / com.example.sam .matrix E / MessageQueue-JNI: java.lang.NullPointerException  

one (and < To properly archive and retrieve the code for Hashmap ), the key type must be overridden by hashode and equal to .

It is necessary to successfully apply the hash code method and the equivalent method used in the form of things.

You have not overridden those methods, so the Hashtable can not find your keys override those methods.


No comments:

Post a Comment