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 2 of 2

Thread: Use HashMap to Call Methods

  1. #1
    Junior Member
    Join Date
    Dec 2012
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Use HashMap to Call Methods

    Hi Guys, Need help with an Assignment.

    I need to create a HashMap, then use it to be able to call methods.
    For example:

    //Maps Key words to responses
    private HashMap<String, String> mapResponder;

    //Constructor
    mapResponder = new HashMap<String, String>();
    fillResponseMap();

    /**
    * List of the responders
    */
    private void fillResponseMap()
    {
    mapResponder.put ("cold",
    "I WANT TO LINK THIS TO A METHOD");
    mapResponder.put ("circle",
    "I WANT TO LINK THIS TO CALL A METHOD");
    }


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    22,265
    Thanks
    56
    Thanked 2,372 Times in 2,343 Posts

    Default Re: Use HashMap to Call Methods

    Please explain what "LINK THIS TO A METHOD" means?
    What will the method do? How will it be called?
    If the value put in the HashMap is an instance of a class, that object could be of a class with a method that can be called.
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. HashMap to Call a Method
    By AbarthGT in forum What's Wrong With My Code?
    Replies: 5
    Last Post: December 10th, 2012, 01:30 PM
  2. buttons that call methods
    By coley909 in forum What's Wrong With My Code?
    Replies: 37
    Last Post: November 28th, 2012, 08:15 AM
  3. call by value and call by reference
    By Appu14 in forum The Cafe
    Replies: 1
    Last Post: September 2nd, 2012, 07:58 AM
  4. Why and where abstract methods & classes and static methods are used?
    By ajaysharma in forum Object Oriented Programming
    Replies: 7
    Last Post: July 14th, 2012, 02:16 AM
  5. Call by Reference & Call by Value
    By Lokesh in forum Java Theory & Questions
    Replies: 1
    Last Post: February 21st, 2011, 01:19 PM