Results 1 to 4 of 4
  1. #1
    Beck3k is offline Member
    Join Date
    Mar 2012
    Posts
    2
    Rep Power
    0

    Default Update Value Hashtable

    Well i dont really know very much about java. Im learning. I have a to do a hashmap with teams and their score so..

    i have this

    public class Clasi {


    Hashtable<String , Integer> scores = new Hashtable<String, Integer>();


    public Clasi(ArrayList<Team> teams){
    Iterator<Team> it=teams.iterator();

    while (it.hasNext()){
    clasi.put(it.next().getName(), 0);
    }

    }



    Now i want to know how to iterate the hashtable and update the values when i have new scores. Thx..

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,307
    Rep Power
    25

    Default Re: Update Value Hashtable

    how to iterate the hashtable
    Read the API doc for the Hashtable class. It has methods that you can use to go throught the hashtables contents.

  3. #3
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default Re: Update Value Hashtable

    Are you using a HashMap or a HashTable?

    And how exactly are you getting data to do the updating?

  4. #4
    Beck3k is offline Member
    Join Date
    Mar 2012
    Posts
    2
    Rep Power
    0

    Default Re: Update Value Hashtable

    Im Using HashTable and for example i have a method wich simulate a match and do random scores between 2 teams, so depends on wich one wins i have to update the score from that team in the hashtable

Similar Threads

  1. Hashtable question. Getting info from a hashtable
    By sindrem in forum New To Java
    Replies: 4
    Last Post: 01-19-2012, 05:00 PM
  2. hashtable
    By vijayabaskar in forum Java Servlet
    Replies: 0
    Last Post: 04-06-2009, 08:20 AM
  3. hashtable
    By vijayabaskar in forum Advanced Java
    Replies: 2
    Last Post: 04-06-2009, 08:05 AM
  4. Hashtable
    By angelicsign in forum New To Java
    Replies: 6
    Last Post: 02-05-2009, 04:30 PM
  5. Hashtable example
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 02-15-2008, 08:43 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •