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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T19:48:33+00:00 2026-06-17T19:48:33+00:00

I am making a simple- code generator (non-random) and I’ve run into a problem.

  • 0

I am making a simple- code generator (non-random) and I’ve run into a problem. The user inputs data into 7 textfields; then contents of which are then placed into an array of type String. My code then takes that array, analyses the different elements and spits out a code that is usable (by me).

However, in my attempt to standardize the String array (aka make every element a lowercase String), it causes the entire program to stop working and I get what appears to be a null pointer exception.

My specific error message is as such:

Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
 at inventorycodeconverter.codeDisplay.calculateData(codeDisplay.java:48)
    at inventorycodeconverter.InventoryCodeConverterView.button1ActionPerformed(InventoryCodeConverterView.java:315)
    at inventorycodeconverter.InventoryCodeConverterView.access$900(InventoryCodeConverterView.java:23)
    at inventorycodeconverter.InventoryCodeConverterView$5.actionPerformed(InventoryCodeConverterView.java:211)
    at java.awt.Button.processActionEvent(Button.java:392)
    at java.awt.Button.processEvent(Button.java:360)
    at java.awt.Component.dispatchEventImpl(Component.java:4630)
    at java.awt.Component.dispatchEvent(Component.java:4460)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)

The section of code that appears to be giving the trouble is goes as such:

public void calculateData(){

     int i;
     for (i = 0; i < calculationBuffer.length; i++){ // calculationBuffer is defined and initialized elsewhere.

         calculationBuffer[i] = calculationBuffer[i].toLowerCase();// this is line 48 where the first error appears to be.
     }


     if (calculationBuffer[0].equals("cap")){
           displayBuffer[0] = "CAP"; // displayBuffer is defined and initialized elsewhere.
     }
     else {
         displayBuffer[0] = "#Error#";
     }


     if (calculationBuffer[1].equals("20/400")) {
           theTA.append("B");
     }
     else if (calculationBuffer[1].equals("20/410")){
           displayBuffer[1] = "C";
     }
     else if (calculationBuffer[1].equals("24/410")){
         displayBuffer[1] = "F";
     }
     else if (calculationBuffer[1].equals("24/415")) {
         displayBuffer[1] = "Y";
     }
     else if (calculationBuffer[1].equals("28/400")){
         displayBuffer[1] = "H";
     }
     else if (calculationBuffer[1].equals("28/415")) {
         displayBuffer[1] = "X";
     }
     else if (calculationBuffer[1].equals("28/410")) {
         displayBuffer[1] = "I";
     }
     else if (calculationBuffer[1].equals("33/400")) {
         displayBuffer[1] = "J";
     }
     else if (calculationBuffer[1].equals("38/400")) {
         displayBuffer[1] = "K";
     }
     else if (calculationBuffer[1].equals("43/400")) {
         displayBuffer[1] = "M";
     }
     else if (calculationBuffer[1].equals("45/400")) {
         displayBuffer[1] = "N";
     }
     else if (calculationBuffer[1].equals("58/400")) {
         displayBuffer[1] = "Q";
     }
     else if (calculationBuffer[1].equals("70/400")) {
         displayBuffer[1] = "S";
     }
     else if (calculationBuffer[1].equals("89/400")) {
         displayBuffer[1] = "T";
     }

 }


 public void displayData() {
      String displayString;
      displayString = Arrays.toString(displayBuffer);
      StringTokenizer st = new StringTokenizer(displayString, ",");

      while(st.hasMoreTokens()){
          String finalText = st.nextToken();

          theTA.append(finalText);
      }
 }
  • 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-17T19:48:34+00:00Added an answer on June 17, 2026 at 7:48 pm

    Somewhere you have declared you array as following (probably):

    String[] calculationBuffer = new String[size];
    

    It’ll intialize all the indexes with nulls. and hence you are getting NPE.

    You should fill all the indexes in a loop as following, before using the array

    for(int i=0; i<size; i++)
    {
        calculationBuffer[i] = "A String";
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the simple JS code for making a simple field editable: <html> <head>
I have this simple code (for making things shorted, the important bits are probably
I'm making a simple URL request with code like this: URL url = new
I'm making a simple app using the HTML5 <canvas> tag and compile the code
Making a simple application, so when the user logs out of Windows, it of
I'm writing a simple QR code generator (just for fun and to learn some
I'm making a game with Python->PyGame->Albow and ran into a problem with board generation.
This one should be pretty simple. I am making a non-MVC ASP.NET 2.0 site.
Okay so i am making a simple reaction game and my code is as
I've got legacy code sample which uses JFreeChart and XYPlot. Now i'm making i18n

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.