Java Java Data Structures Efficiency! Using a Map to store Contact Methods

Naval Kulkarni
Naval Kulkarni
11,251 Points

What is this error?

I am not getting this error. it is saying there is some error on the line where we have written in which package we are. Please tell me what's wrong.

com/example/model/Contact.java
package com.example.model;

import java.util.Map;
import java.util.Set;
import java.util.HashMap;

class Contact {
  private String mFirstName;
  private String mLastName;
  private Map<String, String> mContactMethods;

  public Contact(String firstName, String lastName) {
    mFirstName = firstName;
    mLastName = lastName;
    /* This stores contact methods by name
     * eg:  "phone" => "(555) 555-1234"
     */
    mContactMethods = new HashMap<String, String>();
  }

  public void addContactMethod(String method, String value) {
    // TODO: Add to the contact method map
    mContactMethods.put(method,value);
  }

  /**
   * Returns the available contact methods.  eg: phone, pager,
   *
   * @return The name of the contact methods that are available
   */
  public Set<String> getAvailableContactMethods() {
    // FIXME: This should return the current contact method names.
    return null;
  }

  /**
   * Returns the value for the contact method if it exists, 
   *
   * @param methodName  The name of the contact method to look up.
   * @return The name of the contact methods that are available
   */
  public String getContactInfo(String methodName) {
    // FIXME: return the value for the passed in *methodName*
    return null;
  }

  public String getFirstName() {
    return mFirstName;
  }

  public String getLastName() {
    return mLastName;
  }

}
Kurt Bitner
Kurt Bitner
12,075 Points

Are you getting the illegal statement error? I've been getting that across all Java code challenges I have tried to do. They are definitely having issues with the code challenges.

1 Answer

Naval Kulkarni
Naval Kulkarni
11,251 Points

Yes. I'm getting "illegal start of expression" error. Errors are in all statements from where the class starts.