• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

howto: print records from Hashtable?

 
Ranch Hand
Posts: 277
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi.
This probably sounds like a silly question because it is one, but I don't know how to do it.
Here is the code which inserts records into a Hashtable

And here is the client applet code snippet which calls the insertTXRecord() public method to insert a records and then calls the getTXRecord() to try and print it (for testing only);

At the moment, Java console is giving me this output:

system datetime stamp: Mar 3, 2004 3:00:03 PM
TXRecord: java.util.Hashtable$Enumerator@1531164

which is not what I want and doesn't make much sense to me.
TIA :-)
 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Returns Enumeration wich is a collection of the elements in the tbl_TXRecords.
To print these element.
 
achana chan
Ranch Hand
Posts: 277
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi. Thanks for taking time to look at my issue and for the code.

However Java console throws this runtime error:

system datetime stamp: Mar 3, 2004 6:34:58 PM
TXRecord size: 1
getApplet exception: null
java.lang.ClassCastException at ConfirmationFrame$prdDtlActionListener.actionPerformed(ConfirmationFrame.java:341)

It's complaining about casting enum.nextElement() as a Hashtable ?
TIA :-)
 
achana chan
Ranch Hand
Posts: 277
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
But then, my technique doesn't work either

Throws compile time error

cannot resolve symbol
method get(java.lang.Object)
class TXRecord
.........System.out.println(obj + ": " + (Hashtable)txrecord.get(obj));

Same old nemesis, canna resolve symbol... :-(
 
We don't have time for this. We've gotta save the moon! Or check this out:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic