Java array length error

时间:2015-07-28 16:11:43

标签: java arrays size

I've an error with an array in java. Array.legth shows 2, but there's only one item in it.
I also tried to convert to list (Array.asList) and I got the same error. The new list size() method shows 2 elements, but again inside there's only one object.
As you can see in the image, the first selected expression is listaIntervinientes, which is an array of 2 (java says), buy with only one item.
The second selected show the .length() expression of the previous expression.
Finally, the third selection is a list created with Arrays.asList(...).
You can see this code below the expressions view.
As a little point, class DecisionFlexEvaluationService is a file automatically generated from a wsdl. I think that's not relevant but...

EDIT: Finally I found the code where the array is initialized: After _call.invokem _resp is the object with a member called intervinientes, which is an array of length=2, but with only 1 child. There's no null second child.

    public com.efx.genapply.webservices.bean.DecisionFlexEvaluationResponse getEvaluation(
        com.efx.genapply.webservices.bean.DecisionFlexEvaluationRequest peticion)
        throws java.rmi.RemoteException {
    if (super.cachedEndpoint == null) {
        throw new org.apache.axis.NoEndPointException();
    }
    org.apache.axis.client.Call _call = createCall();
    _call.setOperation(_operations[0]);
    _call.setUseSOAPAction(true);
    _call.setSOAPActionURI("");
    _call.setEncodingStyle(null);
    _call.setProperty(org.apache.axis.client.Call.SEND_TYPE_ATTR,
            Boolean.FALSE);
    _call.setProperty(org.apache.axis.AxisEngine.PROP_DOMULTIREFS,
            Boolean.FALSE);
    _call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS);
    _call.setOperationName(new javax.xml.namespace.QName(
            "http://webservices.genapply.efx.com", "getEvaluation"));

    setRequestHeaders(_call);
    setAttachments(_call);
    try {
        java.lang.Object _resp = _call
                .invoke(new java.lang.Object[] { peticion });

        if (_resp instanceof java.rmi.RemoteException) {
            throw (java.rmi.RemoteException) _resp;
        } else {
            extractAttachments(_call);
            try {
                return (com.efx.genapply.webservices.bean.DecisionFlexEvaluationResponse) _resp;
            } catch (java.lang.Exception _exception) {
                return (com.efx.genapply.webservices.bean.DecisionFlexEvaluationResponse) org.apache.axis.utils.JavaUtils
                        .convert(
                                _resp,
                                com.efx.genapply.webservices.bean.DecisionFlexEvaluationResponse.class);
            }
        }
    } catch (org.apache.axis.AxisFault axisFaultException) {
        throw axisFaultException;
    }
}

enter image description here

1 个答案:

答案 0 :(得分:0)

Is it possible you created your array like this:

Type name[]=new Type[2];

If this is the case name.length will alway give you 2 no matter how many elements you have already "put in". And converting this array to a list creates a list of the size name.length since the list cant know if the nulls in the array are intended or not.