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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T07:34:19+00:00 2026-06-07T07:34:19+00:00

I’m getting a NullPointerException and can’t figure out why. I have read a lot

  • 0

I’m getting a NullPointerException and can’t figure out why. I have read a lot of the questions on here and can’t seem to dissect anything well enough to get the answers I need. I’m working with a HashMap and I’m trying to reference it from a different module.

Here is the code:

import java.util.*; 
@SuppressWarnings("unused")
public class Decoder 
{
    public static void main(String[] args)
    {
        decrypt();
        keywork(null);
    }

    static void decrypt()
    {
        String codedline = "ilyh wkrxvdqg, wzr kxqguhg dqg qlqhwb-wkuhh".toLowerCase();
        char[] cwarr = codedline.toCharArray();
        String dcline  = "";
        for(char x : cwarr)
        {
            if(Character.isLetter(x))
            {
                int c = (int)x;
                c = c - 3;
                if(c > 90 && c < 97)
                {
                    c += 26;
                }
                x = (char)c;
                dcline += x;
            } else
            {
                dcline += x;
            }
        }
        System.out.println(dcline);
    }

    static void keywork(String dcline)
    {
        int x;
        for(int i = 1, sw = 0; i == dcline.length(); i++)
        {
            String strchk = dcline.substring(sw, i);
            Object n = hm.get(strchk);
        };
    }


    static final HashMap<String, Integer> hm = new HashMap <String, Integer>()
    {
        /**
         * 
         */
        private static final long serialVersionUID = 2688387173090905196L;
        {
            hm.put("ONE", 1);
            hm.put("TWO", 2);
            hm.put("THREE", 3);
            hm.put("FOUR", 4);
            hm.put("FIVE", 5);
            hm.put("SIX", 6);
            hm.put("SEVEN", 7);
            hm.put("EIGHT", 8);
            hm.put("NINE", 9);
            hm.put("TEN", 10);
            hm.put("ELEVEN", 11);
            hm.put("TWELVE", 12);
            hm.put("THIRTEEN", 13);
            hm.put("FOURTEEN", 14);
            hm.put("FIFTEEN", 15);
            hm.put("SIXTEEN", 16);
            hm.put("SEVENTEEN", 17);
            hm.put("EIGHTEEN", 18);
            hm.put("NINETEEN", 19);
            hm.put("TWENTY", 20);
            hm.put("THIRTY", 30);
            hm.put("FOURTY", 40);
            hm.put("FIFTY", 50);
            hm.put("SIXTY", 60);
            hm.put("SEVENTY", 70);
            hm.put("EIGHTY", 80);
            hm.put("NINETY", 90);
            hm.put("HUNDRED", 100);
            hm.put("THOUSAND", 1000);
        }
    };
} 

This is what I’m getting:

java.lang.ExceptionInInitializerError
Caused by: java.lang.NullPointerException
at Decoder$1.<init>(Decoder.java:56)
at Decoder.<clinit>(Decoder.java:49)
Exception in thread "main" 
  • 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-07T07:34:21+00:00Added an answer on June 7, 2026 at 7:34 am

    I have never done what you’re trying to do so I don’t know if it will work the way I think it will, but I can see exactly what’s wrong.

    You have used an anonymous subclass syntax with your declaration (probably by accident):

    public static Something object = new Something()
    {
        // anonymous subclass declaration here
    }
    

    The result of that is that, during the initialization of hm, you reference it, which (since you’re currently running in hm‘s constructor, is uninitialized. I’m frankly not even sure how that managed to compile but you should be able to make it work with the following.

    static final HashMap<String, Integer> hm;
    
    static
    {
        hm = new HashMap <String, Integer>()
        {
            private static final long serialVersionUID = 2688387173090905196L;
        }
        hm.put("ONE", 1);
        // snip
        hm.put("THOUSAND", 1000);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I know there's a lot of other questions out there that deal with this
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.

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.