• 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

want to make a table~~~

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
do u know how to make a table for a data? whats its code?



these r my arraylists~~~and how can i make a table for them???
thanks a lot~~~
 
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What sort of a table? A html table to display them? If that is the case you might want to consider using a JSP. If you want to use a Hashtable, then just define one...need more information to help you I think.
 
Alex cordes
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Jody Brown:
What sort of a table? A html table to display them? If that is the case you might want to consider using a JSP. If you want to use a Hashtable, then just define one...need more information to help you I think.



thanks for ur reply
just a Hashtable,i m tring to write a Problem Class Register program. and i want to write a table to display who is present in the class in which day... ...
 
Jody Brown
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A Hashtable is just defined as:



Elements are added to it using:



Elements are obtained using:



Hashtables are in the java.util package, and store a table of data in key-value pairs.

Hope this helps.
 
Jody Brown
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A slight correction to one of my code snippets...

This:



Should read:



the get() method returns an object, thus the cast is needed. Any object can be stored as the key or value, the String was just an example.
 
Alex cordes
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thank you for ur reply~~~
i dont quite get ("aKey", "aValue")... ...
i have two vailables: NAMEs and DATEs
so how can i put these two vailables into this hashtable?
 
Ranch Hand
Posts: 464
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A hashtable maps a key and a value - so you can choose one of your data items (lets say for example name) as the key and put that into the hastable with it's associated date - this provides a link between your name and date values.

The point of this is to retrieve a value from it's associated key.

(p.s. Tildas are a bit annoying )
 
Ranch Hand
Posts: 1780
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
http://java.sun.com/docs/books/tutorial/collections/index.html
 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What question will you ask of this table ...

Who was in class on 11/17?

or

On what days did Bob attend?

I think either way you'll want more than just a Hashmap. In the first example, the date would be the key and you want the map to give you a bunch of people who were there that day. In the second example, the name would be the key and you'd want a bunch of dates that person was present.

Does that make sense so far? While you're looking at the collections tutorial, see if you spot a few choices to hold a "bunch" of names or dates.
 
reply
    Bookmark Topic Watch Topic
  • New Topic