my dog learned polymorphism*
The moose likes Beginning Java and the fly likes want to make a table~~~ Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "want to make a table~~~ " Watch "want to make a table~~~ " New topic
Author

want to make a table~~~

Alex cordes
Greenhorn

Joined: Nov 15, 2005
Posts: 15
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~~~
Jody Brown
Ranch Hand

Joined: Nov 09, 2005
Posts: 43
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

Joined: Nov 15, 2005
Posts: 15
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

Joined: Nov 09, 2005
Posts: 43
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

Joined: Nov 09, 2005
Posts: 43
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

Joined: Nov 15, 2005
Posts: 15
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?
Rick Beaver
Ranch Hand

Joined: Dec 14, 2004
Posts: 464
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 )


ph34r my 133t j4v4 h4><0r1ng sk177z
Jeff Albertson
Ranch Hand

Joined: Sep 16, 2005
Posts: 1780
http://java.sun.com/docs/books/tutorial/collections/index.html


There is no emoticon for what I am feeling!
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
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.


A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: want to make a table~~~
 
Similar Threads
I WANT2 CHANGE METHOD, BUT IT DOESNT WORK, HELP~
declaration
cannot apply...wrong type or wrong operator?help please!
How can final and transient be used in a variable declaraion?
how to Initialize an ArrayList in a constructor with no parameters?