[SalesForce] get selected values of Picklist (Multi-Select) as list of string

I'm trying to get selected values and labels of picklist (Multi-Select) for a record of custom object and store these values in list of string but size of it not displayed.

Apex Class

public with sharing class customCtrl {
    private ApexPages.standardController stdController;

    Id recordId = 'a0Z25000001Vq02';
    public String[] tmpString { set {
        customObj__c a = [SELECT list_tasks__c
                          FROM customObj__c
                          WHERE Id =: recordId limit 1];
        this.tmpString = a.list_tasks__c.split(';');
    } get;}


    public customCtrl(ApexPages.StandardController controller) {
            this.stdController = stdController;
    }
}

VisualForce Page

<apex:page standardController="customObj__c" extensions="customCtrl" >
  <!-- Begin Default Content REMOVE THIS -->
  <apex:form >
  <apex:pageBlock title="List of Selected">
      <apex:pageBlockSection >
          list length is {!tmpString.size}

      </apex:pageBlockSection>
  </apex:pageBlock>
  </apex:form>
  <!-- End Default Content REMOVE THIS -->
</apex:page>

Best Answer

Change your controller code and add code into constructor

public with sharing class customCtrl {


    private ApexPages.standardController stdController;

    public List<String> tmpString {get; private set}

    public customCtrl(ApexPages.StandardController controller) {
            this.stdController = stdController;
            Id recordId = 'a0Z25000001Vq02';
            tmpString = new List<String>();
            customObj__c a = [SELECT list_tasks__c
                          FROM customObj__c
                          WHERE Id =: recordId limit 1];
            tmpString.addAll(a.list_tasks__c.split(';'));

    }
}