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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T21:07:39+00:00 2026-06-15T21:07:39+00:00

I am having an issue with a String array and trying to add it

  • 0

I am having an issue with a String array and trying to add it to a list (List).
Below is the code that is used and creating the issue.

The program fails on the first run through of the loop and I have verified the input which comes from a CSV using OpenCSV.

List<String[]> output = null;
String[] temp;

for(int i = 0; i < 13; i++)
{               
    temp = reader.readNext();                           //read next line into temp
    System.out.println(temp[0]+temp[1]+temp[2]);        //temp output
    temp[2] = String.valueOf((values[i])/100);          //assign new value
    System.out.println(temp[0]+temp[1]+temp[2]);        //temp output
    output.add(temp);
}

When this code runs the output is.

VANCBULLET0.311
VANCBULLET0.308
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
    at Main.updateCSV(Main.java:951)
    at Main.start(Main.java:863)
    at Main.access$23(Main.java:853)
    at Main$23.actionPerformed(Main.java:520)
    at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
    at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
    at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
    at javax.swing.DefaultButtonModel.setPressed(Unknown Source)

The first two lines are correct and are split up like:
temp[0] temp[1] temp[2]
VANC BULLET 0.311
VANC BULLET 0.308

The issue is (like the error reads) at:

output.add(temp);

The documentation reads:

NullPointerException - if the specified element is null and this list does not permit null elements

but as you can see from my output (the second line) the array “temp” is not null, it contains “VANC BULLET 0.308” in each element respectively.

I’m stumped. Does anyone have an idea or see something I have failed to see?

Thanks

  • 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-15T21:07:41+00:00Added an answer on June 15, 2026 at 9:07 pm

    From what i can see you never initialized List<String[]> output = null; in your code. Thus when it call’s List.add as List is still null it throws NPE

    initialize it first:

    List<String[]> output = new ArrayList<String[]>();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have simplified an issue that I've been having trying to isolate the problem,
The issue that I am having is that I am trying to build a
I'm having a real issue trying to parse an XML file that is structured
I am having an issue trying to post a JSON string using dojo.xhrPost to
I'm currently having an issue storing mouse coordinates into an array in which a
I'm having a strange issue converting a string to a date: NSString *goodDateString =
Hi I am having an issue with a MySQL query not passing a string
I am having an issue removing %3Cbr+%2F%3E from my string using the preg_replace function.
I'm facing a problem to solve this issue. I'm having a string variable, for
I am having issues with trying to convert an UTF-8 string to unicode. I

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.