java - Hashmap issues, getting exception I don't understand -


I'm getting a NullPointerException and it does not understand why I'm here Have read a lot of questions and I can not find any good piece of laminate so that I can fulfill my needs. I am working with a hashmap and I am trying to refer it to a different module.

Here's the code:

  import java.util *. @SuppressWarnings ("unused") public class decoder {public static zero main (string [] args) {decrypt (); Keywork (zero); } Fixed decryption from zero () {string codedline = "ilyh wkrxvdqg, wzr ​​kxqguhg dqg qlqhwb-wkuhh" .toLowerCase (); Four [] coil = coded line Charaire (); String decline = ""; For (four x: cavalry) {if (Character.isLetter (x)) {int c = (int) x; C = C-3; If (C & gt; 90 & amp; amp; amp; amp; amp; amp;; & gt; 97) {c + = 26; } X = (four) C; DCline + = X; } And {dcline + = x; }} System.out.println (DCline); } Fixed zero keywork (string decline) {int x; For (int i = 1, sw = 0; i == dcline.length (); i ++) {string string = dcline.substring (sw, i); Object n = hm.get (strchk); }; } Fixed final hashmap   

This is what I am getting:

  generated by java.lang.ExceptionInInitializerError: java.lang.NullPointerExceptionDiscoder $ 1. & Lt; Init & gt on decoder (decoder.java 56). & Lt; Cleit & gt; (Decoding.Java 49) Exception in thread "main"    

I never did that What you are trying to do, I do not know that the way I think it will work, but I can see exactly what is wrong.

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

  public fixed something = something new () {// anonymous Subclass declaration here}   

As a result, during the commencement of hm , you refer to it, (since you are currently hm < / Code>) S constructor is unplanned. I am not clearly sure how he compiled Managed to do it, but you should be able to work with the following.

  static final Hashmap < String, integer & gt; Hm; Stable {hm = new hashmap & lt; String, integer & gt; () {Private Static Final Long Serial UID = 2688387173090905196 L; } Hm.put ("ONE", 1); // snip hm.put ("thousand", 1000); }    

Comments