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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T19:15:03+00:00 2026-06-10T19:15:03+00:00

In the below code, my expectation is if list readerList.size = 0 , headerLine

  • 0

In the below code, my expectation is if list readerList.size = 0, headerLine should be null inside the method commonValidation(). But this is not the case, can anyone tell me why?

String[] headerLine = null;

if (readerList != null && readerList.size() != 0){
    headerLine = readerList.get(0);         
}

commonValidation(headerLine, logDTO, hrGroupName, feedFileName);

//method definition

public void commonValidation(String[] headerLine, TransactionLogDTO logDTO, String hrGroupName, String filename) throws PersistenceException, ServiceException, Exception {
    if ((headerLine == null) || (headerLine.length == 0)){
        logDTO.setGyr("R");

            String subject = MessageWrapper.getMessage("hr.mail.emptyfile.subject");
        String body = MessageWrapper.getMessage("hr.mail.emptyfile.body", filename);

            if (logDTO.getMessage() == null){
                logDTO.setMessage(body);
            }
            else{
                logDTO.setMessage(logDTO.getMessage() + ";" + body);
            }

        logDTO.setIsLogErrorMailSent(Boolean.TRUE);

        sendTransactionLogErrorReport(hrGroupName, subject, body);                  

        throw new Exception(body);
    }
}
  • 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-10T19:15:04+00:00Added an answer on June 10, 2026 at 7:15 pm

    String[] headerLine = null; is this a member variable? if yes then make it method local variable.

    Also

    You can add null elements in ArrayList and size is increased.

        ArrayList<String[]> arrayList = new ArrayList<String[]>();
        arrayList.add(null);
        System.out.println(arrayList.size());
    

    Will Print 1 not 0.

    So check readerList.get(0) is null or not

    Here is the source code of ArrayList add method

     410       public boolean add(E e) {
     411           ensureCapacityInternal(size + 1);  // Increments modCount!!
     412           elementData[size++] = e;
     413           return true;
     414       }
    

    If you see there is no check of null so you will have to do it yourself 🙂

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

Sidebar

Related Questions

Below code not work, but it's work fine for jsf1.2. Now the framework is
Below code is working for list view, but i want to use listbox instead
Below code works fine in Firefox, but not in IE8. It triggers mouse click
In below code when I click 'Vote' a vote results screen is displayed but
Below code is working properly now. But if I replace 'text.txt' with ' http://google.com
Below code checks for last item but I need to check for the second
Below code only showing the textfield, but I want to include textfield and textarea.
Below code is working but why ? Where does the x and y coming/saved
The below code is working fine. But if i change the html string in
The below code is in my javascript/jquery script, but for some reason Firebug tells

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.