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 8761153
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T15:13:10+00:00 2026-06-13T15:13:10+00:00

Im working on a school assignment, and im supposed to make a array of

  • 0

Im working on a school assignment, and im supposed to make a array of hashmap like this:

HashMap<String, Person>[] mood = (HashMap<String, Person>[])  new HashMap<?, ?>[6];

im reading from a file, it goes something like this. the problem is that it gives NullPointerException where i try to put the mood into mood[0]! cant find anything about how the hashmap-array works in my books.. 🙁 would be happy for all help (:

Person p = new Person();
p.name = word[1];
p.age = word[2];
p.mood = word[3];

people.put(p.name, p);

 if (p.mood.equals("HAPPY")) {
 mood[0].put(p.mood, p); //NullPointerException 
 }
  • 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-06-13T15:13:11+00:00Added an answer on June 13, 2026 at 3:13 pm

    Basically, you did initialize an array of mood, but it’s initialized with nulls. So before you can call any method on mood[0] (or at any other indices), you need to put a non-null object inside mood[0].

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

Sidebar

Related Questions

I've been working on this school assignment. The assignment told us to make an
I'm working on a school assignment and I've been completely stumped with this step.
I'm working on this for a school assignment http://cit.dixie.edu/cs/1410/asst_bulkrename.html . I just finished coding
I have this school assignment that I've been working on and am totally stumped
I am working on a school assignment that requires me to be able to
I am working on an mySQL assignment for school and I am stuck on
I'm working on a project for school, and faced this elementary problem (it's not
I am working on a school project that uses ASP.NET. I found this TextEditor
I'm working on my first GWT-based Java project for a school assignment. It's a
This is a school assignment and I have most of it under control, but

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.