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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T20:27:37+00:00 2026-05-31T20:27:37+00:00

Trying to compare and print only members with Inactive status. The problem is that

  • 0
  1. Trying to compare and print only members with Inactive status. The problem is that it will not search the array and check the status of each element. If the first element has an “Active” status, it prints the error message and doesnt continue to check the other elements.
  2. If the status of the first element is “Inactive” it will print but throws an exception before the output which looks like this:

    Exception in thread “main” java.lang.NullPointerException at
    GymAss.MemberTest.AllInactive(MemberTest.java:293) at
    GymAss.MemberTest.main(MemberTest.java:58)

  3. Account Number: 1 Name: 1 Date: 1 Status: INACTIVE Type: 1 Any
    help would be greatly appreciated! Code below:

….

 public static void AllInactive()

    {
    int check=0;
    do  

        {
        if ( accounts[check] instanceof Student && accounts[check].getStatus().equals("INACTIVE") )                
        {


            System.out.printf("\nAccount Number: %d \nName: %s  \nDate: %d \nStatus: %s \nType: %s \n" , accounts[check].getIdNumber(),accounts[check].getName(),accounts[check].getDateJoined(),accounts[check].getStatus(),accounts[check].getMemberType());
            check++;

        }
        else if ( accounts[check] instanceof Adult && accounts[check].getStatus().equals("INACTIVE"))
            {


                System.out.printf("\nAccount Number: %d \nName: %s \nDate: %s \nStatus: %s \nType: %s \n" , accounts[check].getIdNumber(),accounts[check].getName(),accounts[check].getDateJoined(),accounts[check].getStatus(),accounts[check].getMemberType());
                System.out.print("\n");
                check++;


            }
        else
        {
        System.out.println("**Account Does Not Exist**");
        }

        } while ( accounts[check].getStatus().equals("INACTIVE"));

}
  • 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-31T20:27:38+00:00Added an answer on May 31, 2026 at 8:27 pm

    Just to make sure we are talking about the same thing: As far as I understood you have an Array containing accounts of persons. What you want to do is get all the accounts which currently are inactive and nothing else.

    Why do you stop your loop if you find an active account? If you have an inactive account followed by an active followed by an inactive again, your loop will stop at the active one, because the condition of while(accounts[check].getStatus().equals("INACTIVE")) is false. You want to check the whole array so you have to loop through the whole array. This can be done with

    for(int check=0; check<accounts.length; check++)

    This checks every account and stops if you reach the end of the array. There is even an easier way. I recommend looking up “java foreach”.

    The cause of your NullPointerException propably is not checking if you reached the end of your array. Let’s assume you have only one inactive Student account in your array and nothing else, your code will do this:

    • check = 0;
    • is accounts[0] a Student and is it inactive? – yes
      • print stuff
      • check = 1
    • skip else if
    • skip else
    • is accounts[1] active? wait, there’s no accounts[1] -> NullPointerException

    I don’t want to give you the complete code because trial and error is a great way of learning so try to fix it with those hints. If you encounter any problems you still can’t solve after a while of thinking, come back.

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

Sidebar

Related Questions

I am trying to compare two tables to find rows in each table that
im trying to compare words of an array using strcmp.Im trying to get each
I was trying to compare with the cube's data with that of data mart
I'm trying to compare a couple of array values stored in a flat file
I am trying to write a program for my course that sorts an array
I have been trying to create a red black tree that only implements an
I took 2 images with a cross point and now I'm trying to compare
Im trying to compare these two chars but on win 32 Visual Studio 2008:
I am trying to compare the performance of several Javascript libraries. Although measuring transaction
I am trying to compare two text files and output the first string in

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.