Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: Question about hashtable

  1. #1
    Member
    Join Date
    Oct 2012
    Posts
    44
    Thanks
    9
    Thanked 2 Times in 1 Post

    Default Question about hashtable

    I have a question about hash tables. How can I make it so it stores all of the user inputs? Need it to store how many the type of cars the person has. I did something similar using stack where i used push, but i dont think it works with hash. Also for some reason i get an error with this code, error in the cars.put, for some reason it does not recognize the .put. Thanks

    import java.util.Hashtable;
    ......
    ......
    Hashtable<String, String> cars = new Hashtable<String, String>();

    cars.put("one", "toyota");

    Multiple markers at this line
    - Syntax error on token(s), misplaced
    construct(s)
    - Syntax error on tokens, delete these
    tokens
    Last edited by leonne; November 4th, 2012 at 12:07 PM.


  2. #2
    Super Moderator helloworld922's Avatar
    Join Date
    Jun 2009
    Posts
    2,895
    Thanks
    23
    Thanked 619 Times in 561 Posts
    Blog Entries
    18

    Default Re: Question about hashtable

    I can't see anything intrinsically wrong with the code you've posted... could you post the code in context as well as copy the full compiler error message?

  3. #3
    Junior Member
    Join Date
    Sep 2012
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Need more info.

  4. #4
    Member
    Join Date
    Oct 2012
    Posts
    44
    Thanks
    9
    Thanked 2 Times in 1 Post

    Default Re: Question about hashtable

    thanks, fix the error, some reason worked on my other program didnt have the <String, String> in the code

  5. The Following 2 Users Say Thank You to leonne For This Useful Post:

    curmudgeon (November 4th, 2012), jps (November 4th, 2012)

Similar Threads

  1. Need someone to write Hashtable code...
    By realrx7 in forum Paid Java Projects
    Replies: 3
    Last Post: April 23rd, 2012, 08:58 PM
  2. Need something like a "Hashtable<String[], Integer>" kind of data type @@
    By Albretch Mueller in forum Java Theory & Questions
    Replies: 2
    Last Post: November 27th, 2010, 10:24 PM
  3. arraylist, hashtable, and 1~2 dimension arrays
    By Perd1t1on in forum Object Oriented Programming
    Replies: 4
    Last Post: July 25th, 2010, 01:25 PM
  4. [SOLVED] Hashtable and Key Size
    By sapzero in forum Collections and Generics
    Replies: 0
    Last Post: January 28th, 2010, 02:31 PM