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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T07:03:34+00:00 2026-05-18T07:03:34+00:00

I keep receiving a NullPointerException while trying to get a string from any array

  • 0

I keep receiving a NullPointerException while trying to get a string from any array (that is encapsulated within a Vector). I cannot seem to stop the error from happening. It’s got to be something simple, however I think that I have been looking at it for too long and I could sure use another set of eyes. Here is my code:

 Vector<Event> details = vector.get(i).getEvent();

 for (int x = 0; x < details.size(); x++) {
      Event eDetails = details.get(x);

      person = eDetails.getEventPerson();
      place = eDetails.getEventPlace()[0];
      time = eDetails.getEventTime()[0];

 }

So when I try to get the item at position 0 in the array (when x is 0) that is returned from eDetails.getEventTime, a NullPointerException is thrown.

Now, when x is 0 I happen to know that the array element at position 0 of the getEventTime() array is an empty string, but it is NOT a null value. When x is 1 or 2, etc. I can retrieve the time just fine.

The problem is that I will still receive the NullPointerException when I try to do things like the following:

 **System.out.println(eDetails.getEventTime.length);**

 or

 String result;

 **if(eDetails.getEventTime[0] == null){**
      result = "";
 } else {
      result = eDetails.getEventTime[0];
 }

Any ideas?

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-05-18T07:03:34+00:00Added an answer on May 18, 2026 at 7:03 am

    Are you sure in your second example, it shouldn’t be:

    if(eDetails.getEventTime() == null)

    Instead of:

    if(eDetails.getEventTime[0] == null)

    Are you making sure you leave the [0] off when you do the null check?

    If the function eDetails.getEventTime() returns null, then you’ll get a NullPointerException when you try to do eDetails.getEventTime()[0];

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

Sidebar

Related Questions

I keep receiving a C2664 conversion error in visual studio It tells me that
I'm trying to implement my own GenericIdentity implementation but keep receiving the following error
I'm trying to mock MouseButtonEventArgs.GetPosition() with Moq, but I keep receiving this error: System.ArgumentException:
I am trying to convert a pretty complicated JSON string with json2.js from json.org
I am trying to make the following recursive function work but keep receiving an
I am not sure what the problem is but I keep receiving this error
Keep in mind that I'm not looking for a list of current browsers to
I keep getting tasks that are above my skill level. How can I address this without coming accross as grossly incompetent?
I keep hearing from associates about grid computing which, from what I can gather,
I keep hearing that div tags should be used for layout purposes and not

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.