function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Mark Z DeanMark Z Dean 

Calling Inner Classes with ()

I have been doing this Trailhead challenge related to SOAP calls. My webservice mock class has the following code:
public class ParkServiceMock implements WebServiceMock {
   public void doInvoke(
           Object stub,
           Object request,
           Map<String, Object> response,
           String endpoint,
           String soapAction,
           String requestName,
           String responseNS,
           String responseName,
           String responseType) {
        //  String byCountry;

        ParkService.byCountryResponse   l = new ParkService.byCountryResponse (); 
        l.return_x  = new List<String>{'Hamburg Wadden Sea National Park','Hainich National Park', 'Bavarian Forest National Park'}; 
        response.put('response_x', l);

        // Create response element from the autogenerated class.
        // Populate response element.
        // Add response element to the response parameter, as follows:
        //response.put('response_x', responseElement); 
The class generated from the WSDL is below:
//Generated by wsdl2apex

public class ParkService {
    public class byCountryResponse {
        public String[] return_x;
        private String[] return_x_type_info = new String[]{'return','',null,'0','-1','false'};
        private String[] apex_schema_type_info = new String[]{'','false','false'};
        private String[] field_order_type_info = new String[]{'return_x'};
    public class byCountry {
        public String arg0;
        private String[] arg0_type_info = new String[]{'arg0','',null,'0','1','false'};
        private String[] apex_schema_type_info = new String[]{'','false','false'};
        private String[] field_order_type_info = new String[]{'arg0'};
    public class ParksImplPort {
        public String endpoint_x = '';
        public Map<String,String> inputHttpHeaders_x;
        public Map<String,String> outputHttpHeaders_x;
        public String clientCertName_x;
        public String clientCert_x;
        public String clientCertPasswd_x;
        public Integer timeout_x;
        private String[] ns_map_type_info = new String[]{'', 'ParkService'};
        public String[] byCountry(String arg0) {
            ParkService.byCountry request_x = new ParkService.byCountry();
            request_x.arg0 = arg0;
            ParkService.byCountryResponse response_x;
            Map<String, ParkService.byCountryResponse> response_map_x = new Map<String, ParkService.byCountryResponse>();
            response_map_x.put('response_x', response_x);
              new String[]{endpoint_x,
            response_x = response_map_x.get('response_x');
            return response_x.return_x;

As you may notice, the byCountryResponse is an inner class but in the earlier code snippet, I can call an inner class like:
ParkService.byCountryResponse l = new ParkService.byCountryResponse();
This is confusing because byCountryReponse also has brackets next to it which is used for a method. How does it allow this for an inner class in Apex?