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
mwicksmwicks 

How to give apex variable names automatically by the program?

 Hi,
In the below javascript and ASP code I'm not giving the variable name directly, it comes from ' Response.Write "a" '.


<script type="text/javascript">


  var <% Response.Write "a" %>=2;
 
  alert(a);                                                                                                    
                                                                                            
</script>

 


I want to do the same thing (Need to give the variable name as the value of "myString.replace(a,w)" ) for the commented line in this apex code.


Partner_Data__c [] str0;Partner_Data__c [] str1;
public void Test() {

        String myString = 'stra';
        String a='a';
               
                 for(Integer i=0;i<cpname.size();i++)
        {
            String w=i.format() ;
          //  myString.replace(a,w)=[select Fund__c,Revenue__c from Partner_Data__c where Company_ID__c=:i];
           // Need to give the variable name as the value of "myString.replace(a,w)"

        }
       
       
     }
Is there a way to do that?