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?

4

3 回答 3

1

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

if(DataArray.length != 0)  //something similar to this
于 2013-08-07T08:20:01.637 回答
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.

于 2013-08-07T08:24:06.317 回答
0

Simply check

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

     if(rowData not null)
     {

     }
}
于 2013-08-07T08:44:45.120 回答