Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1054003
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T17:20:16+00:00 2026-05-16T17:20:16+00:00

HashMap savedStuff = new HashMap(); savedStuff.put(symbol, this.symbol); //this is a string savedStuff.put(index, this.index); //this

  • 0
HashMap savedStuff = new HashMap();
savedStuff.put("symbol", this.symbol); //this is a string
savedStuff.put("index", this.index); //this is an int

gives me the warning:

HashMap is a raw type. References to generic type HashMap<K,V> should be parameterized  
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T17:20:17+00:00Added an answer on May 16, 2026 at 5:20 pm

    I’m not sure what you’re trying to do, but since the example you provided uses hard-coded strings to index the data, it seems like you know what data you want to group together. If that’s the case, then a Map is probably not a good choice. The better approach would be to make a class out of the commonly grouped data:

    public class SavedStuff {
      private int index;
      private String symbol;
    
      public SavedStuff(int index, String symbol) {
        this.index = index;
        this.symbol = symbol;
      }
    
      public int getIndex() {
        return index;
      }
    
      public String getSymbol() {
        return symbol;
      }
    }
    

    This allows your client code to do this:

    SavedStuff savedStuff = ...
    String symbol = savedStuff.getSymbol();
    

    Rather than this:

    Map<String, Object> savedStuff = ...
    String symbol = savedStuff.get("symbol");
    

    The former example is much less fragile because you’re not indexing data with String constants. It also gives you a place to add behavior on top of your grouped data, which makes your code much more object oriented.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a variable of type Hashmap <String,Integer >. In this, the Integer value
HashMap<String, int> doesn't seem to work but HashMap<String, Integer> does work. Any ideas why?
private HashMap<String, IMapper> mapper = new HashMap<String, IMapper>(); Seems so innocent yet Eclipse is
If i use: HashMap<String, Integer> test = new HashMap<String, Integer>(); Or i use: HashMap
I have a HashMap (although I guess this question applies to other collections) of
HashMap selections = new HashMap<Integer, Float>(); How can i get the Integer key of
I have this HashMap that I need to print out in ascending order according
I was using HashMap before like public Map<SocketChannel, UserProfile> clients = new HashMap<SocketChannel, UserProfile>();
I would like to serialize a HashMap as a string through the Jackson JSON
Suppose we have a HashMap<String, Integer> in Java. How do I update (increment) the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.