[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 796
  • Last Modified:

my program.java uses unchecked or unsafe operations

Note: solutions/mud/Bag.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.


Can anyone tell me what I did wrong?


import java.util.Map;
import java.util.HashMap;
import java.util.List;
import java.util.Vector;
import java.util.Iterator;
import java.io.Serializable;

// Represents a location in the MUD (a vertex in the graph).
class Bag implements Serializable
{


    public HashMap bag = new HashMap();
    
    public void add( String user, String thing )
    {
	    
	    bag.put(user, thing);
	   
    }


}

Open in new window

0
static86
Asked:
static86
  • 2
1 Solution
 
objectsCommented:
try this:

    public HashMap bag = new HashMap();
   
    public void add( String user, String thing )
    {
           
            bag.put(user, thing);
           
    }
0
 
objectsCommented:
the error is saying you haven't specified the type of objects that will be stored in the map
0
 
static86Author Commented:
thx:)!
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now