0

I want to check the condition whether string array gives value or null.

String function:

String rowData[] = (String[]) ArrayUtils.subarray(DataArray, startIndex,
                                         (startIndex + maxColumnCount));

if(rowData not null)
{

}

Value of data array is coming by:

String DataArray[] = request.getParameter("values").split(",");

What would be in if Condition?

2

3 Answers 3

1

Check the length/size of the array is zero or not

if(DataArray.length != 0)  //something similar to this
Sign up to request clarification or add additional context in comments.

1 Comment

yes, but i wanted to check it with rowData, its working now. Thnks :)
0

The request parameter could not have been given and yield null.

String dataArrayParam = request.getParameter("values");
String[] dataArray = dataArrayParam == null?
    new String[0] : dataArrayParam.split(",");

In general it would be:

if (rowData != null) {

BTW. String[] is a more conventional notation, String a[] comes from C compatibility in the early days of Java.

Comments

0

Simply check

if(DataArray != null)
{
     String rowData[] = (String[]) ArrayUtils.subarray(DataArray, startIndex,
                                         (startIndex + maxColumnCount));

     if(rowData not null)
     {

     }
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.