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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T09:57:17+00:00 2026-05-31T09:57:17+00:00

I am trying to mommertary use a string and convert it to an int

  • 0

I am trying to mommertary use a string and convert it to an int to compare the first first column and all the rows with the all of the numbers within the string typed in. When I type in a number, I get a NullPointerException. The thing is, I don’t understand why the compiler is telling me this when I feel like I have declared all my objects properly. please help!

import java.util.ArrayList;

public class Decoder
{

    private int[][] zipdecoder;
    private ArrayList<Integer> zipcode;
    private String finalCode;
    private String bars;
    private int place;
public Decoder()
{
   int[][] zipdecoder = new int[][]{
       {1,0,0,0,1,1},
       {2,0,0,1,0,1},
       {3,0,0,1,1,1},
       {4,0,1,0,0,0},
       {5,0,1,0,1,1},
       {6,0,1,1,0,0},
       {7,1,0,0,0,0},
       {8,1,0,0,1,1},
       {9,1,0,1,0,0},
       {0,1,1,0,0,0}
       };
    zipcode = new ArrayList<Integer>();
}

public void insertToArray(String zip)
{
    int count = 0;

    for(int i = 1; i<zip.length()+1;i++)
    {
        String piece = zip.substring(count, i);

        int number = Integer.parseInt(piece);
        for(int j = 0;j<10;j++)
        {
            if(number == zipdecoder[j][0]){
            for(int a = 1;a<5;a++)
            {
                zipcode.add(place,zipdecoder[j][a]);
                place++;
            }
        }
        count++;
    }

    }
}
  • 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-31T09:57:18+00:00Added an answer on May 31, 2026 at 9:57 am

    You’re not initializing the class member zipdecoder but a new local variable (with the same name) in the constructor.

    Change this

     int[][] zipdecoder = new int[][]{
    

    to

     zipdecoder = new int[][]{
    

    and it should work.

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

Sidebar

Related Questions

Trying to add the ability to delete a Folder using FTP and all subfolders
Trying to get a list of all possible combinations of 2 arrays passed in
Trying to call this function in C without any real luck: int sendcommand(char str[256],
Trying to read registry keys remotly (from a host on local intranet)... All the
Trying to use log4j's built-in JMSAppender to log messages to a local message queue
trying to insert a record in my DB using AJAX for the very first
Trying to use LayerDrawable (defined in XML as layer-list) to layer several shape drawables
Trying to keep all the presentation stuff in the xhtml on this project and
Trying to match this data, that is contained in one string: vsan 1 interfaces:
Trying to work by the design guidelines for GIL, I use bits__ for my

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.